Opened 8 years ago

Closed 5 years ago

#10267 closed Bugs (wontfix)

boost::enable_if_c incorrect result on IBM xlC compiler

Reported by: Daniel Beer <dbeer1@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: core
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

Getting unexpected results when using boost::enable_if_c with boost::is_same on the IBM xlC, while Sun Studio and gcc yield the correct result:

Test program test.cpp:

#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <iostream>

template<typename Key, class Enable = void>
struct not_bool {
    static const bool value = false;
};

template<typename Key>
struct not_bool<Key, typename boost::enable_if_c<
                                    !boost::is_same<Key, bool>::value>::type> {
    static const bool value = true;
};

int main(int argc, char **argv) {
    std::cout << not_bool<bool>::value << std::endl;
    std::cout << not_bool<unsigned long>::value << std::endl;

    return 0;
}

Using xlC:

$ xlC_r -qversion
IBM XL C/C++ for AIX, V11.1 (5724-X13)
Version: 11.01.0000.0010
$ xlC_r test.cpp -o test
$ ./test
0
0

Using Sun Studio:

$ CC -V
CC: Sun C++ 5.10 SunOS_sparc Patch 128228-25 2013/02/20
$ CC test.cpp -o test
$ ./test
0
1

Using gcc:

$ g++ -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
$ g++ test.cpp -o test
$ ./test
0
1

Change History (3)

comment:1 by viboes, 8 years ago

Component: Noneutility
Owner: set to No-Maintainer

comment:2 by Steven Watanabe, 8 years ago

This looks like a compiler bug. In any case, I highly doubt that there's any way to work around this in boost::enable_if_c. Does it work without the "!"? What about if you use enable_if instead of enable_if_c?

comment:3 by Andrey Semashev, 5 years ago

Component: utilitycore
Owner: changed from No-Maintainer to Peter Dimov
Resolution: wontfix
Status: newclosed

I agree with Steven's comment and given there was no response in 2 years I'm closing the ticket.

Note: See TracTickets for help on using tickets.