Boost logo

Boost :

Subject: Re: [boost] [Config] N3276 decltype support on VC++ 11
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2012-09-10 20:41:01


[Michel Morin]
> For a function `const int f()`, `decltype(f())` returns `int` on VC++ 11.
> So some `result_of` tests fail as in #6754.
> ( https://svn.boost.org/trac/boost/ticket/6754 )
> Clang 3.1 and gcc 4.7-4.8 behaves similarly, and this behavior
> conforms to the C++11 Standard.

I'm confused, because I observe this with VC11 RTM:

C:\Temp>type meow.cpp
#include <stdio.h>

template <typename T> struct Print;

template <> struct Print<int> {
    static void print() { puts("int"); }
};

template <> struct Print<const int> {
    static void print() { puts("const int"); }
};

const int f() { return 1729; }

int main() {
    printf("%02d.%02d.%05d.%02d\n", _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000, _MSC_BUILD);

    Print<decltype(f())>::print();
}

C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp

C:\Temp>meow
17.00.50727.01
const int

I see N3376 3.10 [basic.lval]/4 "Class prvalues can have cv-qualified types; non-class prvalues always have cv-unqualified types." so I am quite willing to believe that "int" is the correct answer here, but before I file a compiler bug I'd like to verify what's going on here.

Thanks,
STL


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk