LLVM program compile error w/ gcc 4.5 but not 4.4

Hi all,

I can compile LLVM+clang (from svn 2.8 branch, fyi) just fine with gcc
4.4.5 and 4.5.1 on Linux/amd64 just fine, and I did successfully built
LLVM+clang on Solaris10/amd64 (32bit built) just fine with gcc 3.3, too.

However, when it comes to compiling my *own* project that builds atop of
LLVM, I'm getting a strange compilation error when using GCC 4.5.1 but
*NOT* when using GCC 4.4.5 on Linux/amd64.
I do also get this error on GCC 4.5.1 on Solaris10/x86 now, and can't just
install a GCC 4.4.5 in order to *just* compile my own stuff.
I cannot test GCC 3.3.5 nor clang (on the Solaris10) though, since my code
requires C++0x features not available in either package.

This is the error:

In file included from
/waflhome/trapni/local/include/llvm/Support/Allocator.h:17:0,
                 from /waflhome/trapni/local/include/llvm/ADT/StringMap.h:18,
                 from /waflhome/trapni/local/include/llvm/PassRegistry.h:20,
                 from /waflhome/trapni/local/include/llvm/PassSupport.h:25,
                 from /waflhome/trapni/local/include/llvm/Pass.h:366,
                 from /waflhome/trapni/local/include/llvm/PassManager.h:20,
                 from
/waflhome/trapni/local/include/llvm/Support/StandardPasses.h:22,
                 from /waflhome/trapni/local/src/flow/src/Runner.cpp:19:
/waflhome/trapni/local/include/llvm/Support/AlignOf.h:57:24: error:
expected unqualified-id before 'alignof'
In file included from
/waflhome/trapni/local/include/llvm/ADT/StringMap.h:18:0,
                 from /waflhome/trapni/local/include/llvm/PassRegistry.h:20,
                 from /waflhome/trapni/local/include/llvm/PassSupport.h:25,
                 from /waflhome/trapni/local/include/llvm/Pass.h:366,
                 from /waflhome/trapni/local/include/llvm/PassManager.h:20,
                 from
/waflhome/trapni/local/include/llvm/Support/StandardPasses.h:22,
                 from /waflhome/trapni/local/src/flow/src/Runner.cpp:19:
/waflhome/trapni/local/include/llvm/Support/Allocator.h: In member
function 'void llvm::SpecificBumpPtrAllocator<T>::DestroyAll()':
/waflhome/trapni/local/include/llvm/Support/Allocator.h:204:46: error:
expected primary-expression before '<' token
/waflhome/trapni/local/include/llvm/Support/Allocator.h:204:48: error:
expected primary-expression before '>' token
/waflhome/trapni/local/include/llvm/Support/Allocator.h:204:50: error:
expected primary-expression before ')' token
In file included from
/waflhome/trapni/local/include/llvm/PassRegistry.h:20:0,
                 from /waflhome/trapni/local/include/llvm/PassSupport.h:25,
                 from /waflhome/trapni/local/include/llvm/Pass.h:366,
                 from /waflhome/trapni/local/include/llvm/PassManager.h:20,
                 from
/waflhome/trapni/local/include/llvm/Support/StandardPasses.h:22,
                 from /waflhome/trapni/local/src/flow/src/Runner.cpp:19:
/waflhome/trapni/local/include/llvm/ADT/StringMap.h: In static member
function 'static llvm::StringMapEntry<ValueTy>*
llvm::StringMapEntry<ValueTy>::Create(const char*, const char*,
AllocatorTy&, InitType)':
/waflhome/trapni/local/include/llvm/ADT/StringMap.h:170:33: error:
expected primary-expression before '<' token
/waflhome/trapni/local/include/llvm/ADT/StringMap.h:170:48: error:
expected primary-expression before '>' token
/waflhome/trapni/local/include/llvm/ADT/StringMap.h:170:50: error:
expected primary-expression before ')' token
/waflhome/trapni/local/src/flow/src/Runner.cpp: In member function 'void
Flow::runner::compile(Flow::Unit*)':
/waflhome/trapni/local/src/flow/src/Runner.cpp:325:99: warning: ISO C++
forbids casting between pointer-to-function and pointer-to-object
/waflhome/trapni/local/src/flow/src/Runner.cpp: In member function 'bool
(* Flow::runner::compile(Flow::Function*))(void*)':
/waflhome/trapni/local/src/flow/src/Runner.cpp:347:67: warning: ISO C++
forbids casting between pointer-to-function and pointer-to-object
make[2]: *** [src/CMakeFiles/flow.dir/Runner.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/flow.dir/all] Error 2
make: *** [all] Error 2

I absolutely have no idea on why GCC 4.5.x doesn't seem to like LLVM's
alignof<> - maybe due to a name-clash with GCC's provides system
headers... I don't know.

Does anyone have a helpful hint here?

Many thanks in advance,
Christian Parpart.

Hi Christian,

/waflhome/trapni/local/include/llvm/Support/AlignOf.h:57:24: error:
expected unqualified-id before 'alignof'

...

I absolutely have no idea on why GCC 4.5.x doesn't seem to like LLVM's
alignof<> - maybe due to a name-clash with GCC's provides system
headers... I don't know.

this should be fixed now if you update to latest LLVM from subversion.

Ciao,

Duncan.