[Bug c++/77462] Error message prints source from wrong file after #line
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77462 Andrew Pinski changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #3 from Andrew Pinski --- Hmm, I think this is expected. Take a good example of why #line are used in the first place: generated files. IF you are playing preprocessor tricks like this, you get what you deserve in the error message. In fact I would say clang got it all wrong.
[Bug c++/77462] Error message prints source from wrong file after #line
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77462 --- Comment #2 from Daniel Frey --- (In reply to Manuel López-Ibáñez from comment #1) Indeed, this is even worse than I thought. FWIW, here's a reduced example for my code: static_assert( 2 + 2 == 4, "oops" ); #line 1 static_assert( 2 + 2 == 5, "oops" ); Leading to the same wrong error message, no explicit setting of the file is necessary to confuse the compiler.
[Bug c++/77462] Error message prints source from wrong file after #line
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77462 Manuel López-Ibáñez changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2016-09-02 CC||manu at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Manuel López-Ibáñez --- I'm pretty sure there was an open bug already about this but I cannot find it. What is even worse is that, even without #line, we cannot display the caret line if the file is preprocessed and the original files cannot be found: # 1 "filenotavailable.cc" # 1 "" # 1 "" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "" 2 # 1 "filenotavailable.cc" int main() { static_assert( 2 + 2 == 5, "oops" ); } $ g++ filenotavailable.ii -std=c++11 filenotavailable.cc: In function ‘int main()’: filenotavailable.cc:3:3: error: static assertion failed: oops