Hi,
I think Martin is right. Preprocessor is only textual replacement, compiler should not know about this step and compiles code resulting from preprocess step.
I used Martin’s source code I have got different number of warnings if preprocess step was made as extra step before compilation, in my opinion it is a bug.
Common sense tells me that this “equation” should be true every time: clang++ -c = clang++ -E + clang++ -c.
Mira
d:\Tmp>clang++ -v
clang version 3.6.0 (220682)
Target: i686-pc-windows-gnu
Thread model: posix
d:\Tmp>clang++ -c foo.cpp
foo.cpp:9:13: warning: ‘this’ pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true
[-Wundefined-bool-conversion]
return (!(this)); // warns
~ ^~~~
foo.cpp:23:12: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always
evaluate to true [-Wtautological-undefined-compare]
return (&r != 0); // warns
^ ~
foo.cpp:30:8: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always
evaluate to true [-Wtautological-undefined-compare]
RET(&r != 0); // does NOT warn
^ ~
foo.cpp:2:13: note: expanded from macro ‘RET’
return (!(expr))
^
3 warnings generated.
d:\Tmp>clang++ -E foo.cpp > foo2.cpp
d:\Tmp>clang++ -c foo2.cpp
foo.cpp:9:13: warning: ‘this’ pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true
[-Wundefined-bool-conversion]
return (!(this));
~ ^~~~
foo.cpp:14:13: warning: ‘this’ pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true
[-Wundefined-bool-conversion]
return (!(this));
~ ^~~~
foo.cpp:23:12: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always
evaluate to true [-Wtautological-undefined-compare]
return (&r != 0);
^ ~
foo.cpp:30:14: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always
evaluate to true [-Wtautological-undefined-compare]
return (!(&r != 0));
^ ~
4 warnings generated.