Compiler warnings with gcc-4.7.1

I just switched gcc from 4.6.2 to 4.7.1 and see the massive amount of warnings, see few examples below.
They mostly didn't exist with gcc-4.6.2.

rev.159224

Yuri

/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:56:10: warning: enumeral mismatch in conditional expression: ‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*> >::<anonymous enum>’ vs ‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> >::<anonymous

[-Wenum-compare]/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:56:10: warning: enumeral mismatch in conditional expression: ‘llvm::PointerLikeTypeTraits<const clang::Type*>::<anonymous enum>’ vs ‘llvm::PointerLikeTypeTraits<clang::TypeSourceInfo*>::<anonymous enum>’ [-Wenum-compare]
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h: In instantiation of ‘class llvm::PointerUnionUIntTraits<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*>, llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> >’:
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerIntPair.h:43:8: required from ‘class llvm::PointerIntPair<void*, 1u, bool, llvm::PointerUnionUIntTraits<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*>, llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> > >’
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:84:11: required from ‘class llvm::PointerUnion<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*>, llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> >’
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:347:11: required from ‘class llvm::PointerUnion4<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*, clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*>’
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/tools/clang/tools/libclang/../../include/clang/AST/Decl.h:1507:5: required from here
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:56:10: warning: comparison between ‘enum llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*> >::<anonymous>’ and ‘enum llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> >::<anonymous>’ [-Wenum-compare]
/usr/home/yuri/llvm-2012-06/latest-unpatched/llvm-fix/include/llvm/ADT/PointerUnion.h:56:10: warning: enumeral mismatch in conditional expression: ‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateDecl*, clang::MemberSpecializationInfo*> >::<anonymous enum>’ vs ‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::FunctionTemplateSpecializationInfo*, clang::DependentFunctionTemplateSpecializationInfo*> >::<anonymous

-Wenum-compare is buggy / bogus. We should turn this warning off in our build scripts if possible.

Hi Chandler,

-Wenum-compare is buggy / bogus. We should turn this warning off in our build
scripts if possible.

is it buggy, or is it bogus? If buggy, then let's report that to gcc. If
bogus, then I guess we can either (1) suppress it locally, or (2) report to
gcc that it shouldn't be included in -Wall.

Ciao, Duncan.

My impression is it’s a bit of both. I believe this has been reported to GCC, I just don’t know the result.

There seems to be some very slim arguments that some parts of this warning is technically accurate according to its warning, but AFAIK, it is not finding any bugs…