Opened 8 years ago

Closed 8 years ago

#10694 closed Bugs (fixed)

Apple Clang + NVCC - identifier "__is_abstract" is undefined

Reported by: nilsgladitz@… Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

While building with nvcc (NVIDIA CUDA compiler) and Clang on Mac OS X I get errors like these:

/usr/local/include/boost/type_traits/is_abstract.hpp(72): error: identifier "is_abstract" is undefined

/usr/local/include/boost/type_traits/is_abstract.hpp(72): error: function call is not allowed in a constant expression

/usr/local/include/boost/type_traits/is_abstract.hpp(72): error: type name is not allowed

/usr/local/include/boost/type_traits/is_enum.hpp(180): error: identifier "is_enum" is undefined

/usr/local/include/boost/type_traits/is_enum.hpp(180): error: function call is not allowed in a constant expression

/usr/local/include/boost/type_traits/is_enum.hpp(180): error: type name is not allowed

Change History (7)

comment:1 by John Maddock, 8 years ago

This looks a lot like a clang bug to me, the code in type_traits/intrinsics.hpp sets the use of is_abstract via:

# if __has_feature(is_abstract)
# define BOOST_IS_ABSTRACT(T) __is_abstract(T)
# endif

So... if clang __has_feature is indicating that __is_abstract is available what are we supposed to do?

Last edited 8 years ago by John Maddock (previous) (diff)

comment:2 by John Maddock, 8 years ago

BTW, forgot to ask, does:

#include <type_traits>

compile? What about if you try to use std::is_abstract?

comment:3 by nilsgladitz@…, 8 years ago

Thank you for looking into this.

#include <type_traits> and use of std::is_abstract seems to work with clang++ when directly invoked.

When I try to run nvcc on it instead I get:

fatal error: 'type_traits' file not found.

Looking at the clang command line that nvcc runs it seems to be due to it adding -stdlib=libstdc++. Forcing -stdlib=libc++ seems to break the subsequent cudafe (CUDA front end) invocation:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/config(226): error: identifier "char16_t" is undefined

It looks like

/usr/local/include/boost/type_traits/is_abstract.hpp(72): error: identifier "is_abstract" is undefined

is also issued by cudafe while compiling the code that clang preprocessed rather than clang itself.

comment:4 by John Maddock, 8 years ago

There should still be <type_traits> available even when -stdlib=libstdc++ is used, unless it's a really old libstdc++ version?

Obviously I could disable the use of clang intrinsics when the compiler is cuda, but then the type traits wouldn't actually work :-( Plus these are also GCC intrinsics, so I'm rather surprised that it's not supported.

in reply to:  4 comment:5 by nilsgladitz@…, 8 years ago

Replying to johnmaddock:

There should still be <type_traits> available even when -stdlib=libstdc++ is used, unless it's a really old libstdc++ version?

Development on OS X is still very new to me so I am not entirely sure if I am looking in all the right places but it seems the libstdc++ version being used is "20070719". The directory it is in seems to suggest this corresponds to gcc 4.2.1.

As far as I understand Apple no longer distributes gcc so they might not be interested in maintaining or upgrading libstdc++.

comment:6 by nilsgladitz@…, 8 years ago

Locally replacing

#if defined(BOOST_CLANG) && defined(__has_feature)

with

#if defined(BOOST_CLANG) && defined(__has_feature) && !defined(__CUDACC__)

in type_traits/intrinsics.hpp does seem to work around this particular issue for me for now.

comment:7 by John Maddock, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.