Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang reports its own version incorrectly #12744

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR12643
Status NEW
Importance P normal
Reported by Luboš Luňák (l.lunak@centrum.cz)
Reported on 2012-04-24 10:05:00 -0700
Last modified on 2014-10-22 14:41:17 -0700
Version trunk
Hardware Other Linux
CC agner@agner.org, anton@korobeynikov.info, geek4civic@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Steps to reproduce:

$ clang++ --version
clang version 3.1
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ cat /tmp/a.cpp
__clang_major__ . __clang_minor__ . __clang_patchlevel__

$ clang++ -E /tmp/a.cpp
# 1 "/tmp/a.cpp"
# 1 "/tmp/a.cpp" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 145 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "/tmp/a.cpp" 2
3 . 1 . 0

This is obviously wrong. Version 3.1.0 has been barely branched, let alone
released. And this does not apply only to development snapshots, but I've been
told that Apple's current XCode does this too and Clang identifies itself as
"3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)".

A specific case of where this is wrong is checking for compiler bugs. For
example, until recently there had been no simple way to check which command
line options clang supports, because even with -Werror Clang just warned about
unknown arguments but proceeded anyway. This will be fixed in the 3.1.0
release, but there is no way to actually identify such release.
Quuxplusone commented 10 years ago
This is very bad!

The Apple Clang version 3.5 has __clang_major__ = 6 and __clang_minor__ = 0 so
as to make believe it is version 6.0. Apparently, there is no way to check for
version numbers across platforms. The documentation says that you should use
the __has_feature() macros (
http://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros ).

But obviously, there is no __has_bug() macro. The __clang_major__ and
__clang_minor__ macros are needed in particular for making work-arounds for
known bugs. This is impossible when version macros are inconsistent! I need to
make a workaround for a known bug, and I need my code to be portable among
platforms.

This bug was reported 2½ years ago. I can't believe it hasn't been fixed yet.
Please fix this ASAP or make a new set of version macros that are reliable.
Quuxplusone commented 10 years ago

Please report the problems with Apple-released binaries to apple bug tracker.