Boost logo

Boost :

Subject: [boost] [result_of] Test fails on clang trunk and gcc-4.7 due to changes in FDIS
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-03-28 07:39:15


In the code below,

        const int f();
        decltype(f()) i = 0;

`i` has type `int` (not `const int`) in C++11.
This is because `f()` is a prvalue of a non-class type (i.e. `const int`)
and so its cv qualifiers are ignored.

C++0x drafts (before FDIS) had a special rule for function calls in decltype:
    if e is a function call or an invocation of an overloaded operator
    (parentheses around e are ignored), decltype(e) is the return type
    of the statically chosen function;
but this was removed in FDIS.

Clang-3.1 (which will be clang-3.1) and gcc-4.7 seem to
have implemented this change, and this change breaks
the test case (libs/utility/test/result_of_test.cpp) on those
compilers in a C++11 mode.

The following are the errors messages:
[1] result_of_test.cpp:210:3: error: static assertion failed:
(is_same<result_of<const
result_of_member_function_template(double)>::type, const
double>::value)
[2] result_of_test.cpp:211:3: error: static assertion failed:
(is_same<result_of<volatile
result_of_member_function_template(double)>::type, volatile
double>::value)
[3] result_of_test.cpp:212:3: error: static assertion failed:
(is_same<result_of<const volatile
result_of_member_function_template(double)>::type, const volatile
double>::value)
[4] result_of_test.cpp:239:3: error: static assertion failed:
(is_same<result_of<const volatile
no_result_type_or_result_of(void)>::type, const unsigned
short>::value)
[5] result_of_test.cpp:244:3: error: static assertion failed:
(is_same<result_of<const volatile
no_result_type_or_result_of_template<void>(void)>::type, const
unsigned short>::value)

Regards,
Michel


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