[type_traits] is_enum on scoped enums doesn't works as expected

Hi, The following file fails to compile under clang 2.9 c++0x #include <boost/static_assert.hpp> #include <boost/type_traits/is_enum.hpp> enum E {E_a,E_b,E_c}; BOOST_STATIC_ASSERT((boost::is_enum<E>::value)); enum class EC {a,b,c}; BOOST_STATIC_ASSERT((boost::is_enum<EC>::value)); //#include <type_traits> The command line and error is "/Users/viboes/clang/clang+llvm-2.9/bin/clang++" -x c++ -std=c++0x -O0 -g -Wextra -Wno-long-long -pedantic -O0 -fno-inline -Wall -pedantic -g -DBOOST_ALL_NO_LIB=1 -DBOOST_CONVERSION_DOUBLE_CP -DBOOST_ENABLE_WARNINGS -I"." -I"../../.." -c -o "../../../bin.v2/libs/enums/test/is_enum_pass.test/clang-darwin-2.9x/debug/is_enum_pass.o" "enum_class/is_enum_pass.cpp" enum_class/is_enum_pass.cpp:7:1: error: static_assert failed "(boost::is_enum<EC>::value)" BOOST_STATIC_ASSERT((boost::is_enum<EC>::value)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from enum_class/is_enum_pass.cpp:1: Am I missing something evident? Is this a known bug of is_enum? BTW, I have tried to use directly the type_traits standard file and my build configuration is unable to find it. enum_class/is_enum_pass.cpp:9:10: fatal error: 'type_traits' file not found #include <type_traits> Which is the default library when buildding with Boost.Build (bjam) and clang 2.9 c++0x? Best, Vicente

Le 21/08/11 11:26, Vicente J. Botet Escriba a écrit :
Hi,
The following file fails to compile under clang 2.9 c++0x
#include <boost/static_assert.hpp> #include <boost/type_traits/is_enum.hpp>
enum E {E_a,E_b,E_c}; BOOST_STATIC_ASSERT((boost::is_enum<E>::value)); enum class EC {a,b,c}; BOOST_STATIC_ASSERT((boost::is_enum<EC>::value));
//#include <type_traits>
BTW, this file compiles well on mingw with gcc-4.5.0,4.5.2,4.6.0 on c++0x mode. Best, Vicente

On 8/21/2011 5:26 AM, Vicente J. Botet Escriba wrote:
Hi,
The following file fails to compile under clang 2.9 c++0x
#include <boost/static_assert.hpp> #include <boost/type_traits/is_enum.hpp>
enum E {E_a,E_b,E_c}; BOOST_STATIC_ASSERT((boost::is_enum<E>::value)); enum class EC {a,b,c}; BOOST_STATIC_ASSERT((boost::is_enum<EC>::value));
//#include <type_traits>
The command line and error is
"/Users/viboes/clang/clang+llvm-2.9/bin/clang++" -x c++ -std=c++0x -O0 -g -Wextra -Wno-long-long -pedantic -O0 -fno-inline -Wall -pedantic -g -DBOOST_ALL_NO_LIB=1 -DBOOST_CONVERSION_DOUBLE_CP -DBOOST_ENABLE_WARNINGS -I"." -I"../../.." -c -o "../../../bin.v2/libs/enums/test/is_enum_pass.test/clang-darwin-2.9x/debug/is_enum_pass.o" "enum_class/is_enum_pass.cpp"
enum_class/is_enum_pass.cpp:7:1: error: static_assert failed "(boost::is_enum<EC>::value)" BOOST_STATIC_ASSERT((boost::is_enum<EC>::value)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from enum_class/is_enum_pass.cpp:1:
Am I missing something evident? Is this a known bug of is_enum?
BTW, I have tried to use directly the type_traits standard file and my build configuration is unable to find it.
enum_class/is_enum_pass.cpp:9:10: fatal error: 'type_traits' file not found #include <type_traits>
Normally this is: #include <boost/type_traits.hpp>

Le 21/08/11 16:56, Edward Diener a écrit :
On 8/21/2011 5:26 AM, Vicente J. Botet Escriba wrote:
Hi,
The following file fails to compile under clang 2.9 c++0x
//#include <type_traits>
BTW, I have tried to use directly the type_traits standard file and my build configuration is unable to find it.
enum_class/is_enum_pass.cpp:9:10: fatal error: 'type_traits' file not found #include <type_traits>
Normally this is:
#include <boost/type_traits.hpp>
I was talking of the C++ standard file :) Berst, Vicente

Vicente Botet wrote:
Hi,
The following file fails to compile under clang 2.9 c++0x
#include <boost/static_assert.hpp> #include <boost/type_traits/is_enum.hpp>
enum E {E_a,E_b,E_c}; BOOST_STATIC_ASSERT((boost::is_enum<E>::value)); enum class EC {a,b,c}; BOOST_STATIC_ASSERT((boost::is_enum<EC>::value));
//#include <type_traits>
The command line and error is
"/Users/viboes/clang/clang+llvm-2.9/bin/clang++" -x c++ -std=c++0x -O0 -g -Wextra -Wno-long-long -pedantic -O0 -fno-inline -Wall -pedantic -g -DBOOST_ALL_NO_LIB=1 -DBOOST_CONVERSION_DOUBLE_CP -DBOOST_ENABLE_WARNINGS -I"." -I"../../.." -c -o "../../../bin.v2/libs/enums/test/is_enum_pass.test/clang-darwin-2.9x/debug/is_enum_pass.o" "enum_class/is_enum_pass.cpp"
enum_class/is_enum_pass.cpp:7:1: error: static_assert failed "(boost::is_enum<EC>::value)" BOOST_STATIC_ASSERT((boost::is_enum<EC>::value)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from enum_class/is_enum_pass.cpp:1:
Am I missing something evident? Is this a known bug of is_enum?
BTW, I have tried to use directly the type_traits standard file and my build configuration is unable to find it.
enum_class/is_enum_pass.cpp:9:10: fatal error: 'type_traits' file not found #include <type_traits>
Which is the default library when building with Boost.Build (bjam) and clang 2.9 c++0x?
Hi, can someone reply to this post? Thanks, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-is-enum-on-scoped-enums-doesn... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Wed Aug 24 2011, Vicente Botet <vicente.botet-AT-wanadoo.fr> wrote:
can someone reply to this post?
Did you ask the Clang people about it? -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote:
on Wed Aug 24 2011, Vicente Botet <vicente.botet-AT-wanadoo.fr> wrote:
can someone reply to this post?
Did you ask the Clang people about it?
No, I didn't. I should try to use clang in standalone mode to check for std::is_enum and <type_traits> access before requesting them anything. I posted this here as I'm using Boost.TypeTraits (boost::is_enum) and Boost.Build and expected that someone could help me here. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-is-enum-on-scoped-enums-doesn... Sent from the Boost - Dev mailing list archive at Nabble.com.

Vicente J. Botet Escriba wrote:
Which is the default library when buildding with Boost.Build (bjam) and clang 2.9 c++0x?
I think it depends on how clang is built and Boost.Build is not relevant here. In my setting, clang uses libstdc++ of gcc-4.2 which does not support C++0x. IIRC, clang does not support newer versions of libstdc++. So, to use the C++0x's standard library, you need libc++ (http://libcxx.llvm.org/). Clang uses libc++ if you pass "-stdlib=libc++" to the compiler. FYI, the code (with modification of `boost::is_enum` to `std::is_enum`) compiles fine with clang and libc++. Regards, Michel

Michel MORIN wrote:
Vicente J. Botet Escriba wrote:
Which is the default library when buildding with Boost.Build (bjam) and clang 2.9 c++0x?
I think it depends on how clang is built and Boost.Build is not relevant here.
In my setting, clang uses libstdc++ of gcc-4.2 which does not support C++0x. IIRC, clang does not support newer versions of libstdc++. So, to use the C++0x's standard library, you need libc++ (http://libcxx.llvm.org/). Clang uses libc++ if you pass "-stdlib=libc++" to the compiler.
FYI, the code (with modification of `boost::is_enum` to `std::is_enum`) compiles fine with clang and libc++.
Hi, thanks for the information. I will add whatever is needed for the library selection when compiling in C++0x mode and see how boost::is_enum behaves to try to understand why boost::is_enum is not working, as is not using the std::is_enum, but IIRC an intrinsic. Thanks again, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-is-enum-on-scoped-enums-doesn... Sent from the Boost - Dev mailing list archive at Nabble.com.

Vicente Botet wrote:
I will add whatever is needed for the library selection when compiling in C++0x mode and see how boost::is_enum behaves to try to understand why boost::is_enum is not working, as is not using the std::is_enum, but IIRC an intrinsic.
Boost.TypeTraits does not use intrinsics for clang yet. (c.f. https://svn.boost.org/trac/boost/changeset/72725) Regards, Michel

Le 25/08/11 13:45, Michel MORIN a écrit :
Vicente Botet wrote:
I will add whatever is needed for the library selection when compiling in C++0x mode and see how boost::is_enum behaves to try to understand why boost::is_enum is not working, as is not using the std::is_enum, but IIRC an intrinsic. Boost.TypeTraits does not use intrinsics for clang yet. (c.f. https://svn.boost.org/trac/boost/changeset/72725)
Thanks, this explains why it is not working now. Is someone working on this issue? Best, Vicente

I will add whatever is needed for the library selection when compiling in C++0x mode and see how boost::is_enum behaves to try to understand why boost::is_enum is not working, as is not using the std::is_enum, but IIRC an intrinsic. Boost.TypeTraits does not use intrinsics for clang yet. (c.f. https://svn.boost.org/trac/boost/changeset/72725)
this explains why it is not working now. Is someone working on this issue?
Not me, we need a Clang expert to look into it - or at least someone with access to Clang to take care of the testing - someone did submit a patch to enable intrinsic support for Clang, but it broke more things than it fixed so it got reverted :-( John.
participants (6)
-
Dave Abrahams
-
Edward Diener
-
John Maddock
-
Michel MORIN
-
Vicente Botet
-
Vicente J. Botet Escriba