Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#6754 closed Bugs (fixed)

[result_of] Test fails on clang trunk and gcc-4.7

Reported by: Michel Morin Owned by: Daniel Walker
Milestone: To Be Determined Component: utility
Version: Boost Development Trunk Severity: Problem
Keywords: C++11 Cc:

Description

In C++11, when a function call expression EXPR is a prvalue of non-class types, decltype(EXPR) does not have cv-qualifiers. This is because

  • decltype(EXPR)is the type of EXPR when a function call expression EXPR is a prvalue;
  • a prvalue of non-class types is never cv-qualified.

So, for "const int f();", decltype(f()) is int.

Because this rule was introduced at the last minute of the C++11 standardization process, only a few compilers implement it for now: clang trunk (which will be clang-3.1) and gcc-4.7. On those compilers in a C++11 mode, the test fails with the following errors.

  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)
    

Change History (2)

comment:1 by Daniel Walker, 10 years ago

Resolution: fixed
Status: newclosed

These test cases are checking that result_of uses the appropriate operator() when there are cv-overloads by using cv-qualification on the return type as a flag. I replaced the return types with a wrapper, cv_overoad_check, that is used to signal which overload was used. Fixed in [80352].

comment:2 by Michel Morin, 10 years ago

Confirmed the fix. The test ran fine on gcc 4.7, 4.8 (experimental) and clang 3.1, 3.2 (trunk). Thanks for the fix, Daniel.

Note: See TracTickets for help on using tickets.