https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120421
Bug ID: 120421 Summary: -save-temps affects diagnostic position Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nightstrike at gmail dot com Target Milestone: --- ``` #define longNameIfy(name) longName ## name #define fcn longNameIfy(fcn) void fcn(int x); void f() { fcn(xxxxx); // comment } ``` Compiling normally: $ /tmp/gcc-14.1-rh7/bin/g++ a.cc -c a.cc: In function 'void f()': a.cc:7:13: error: 'xxxxx' was not declared in this scope 7 | fcn(xxxxx); // comment | ^~~~~ Compiling with save-temps: $ /tmp/gcc-14.1-rh7/bin/g++ a.cc -c -save-temps a.cc: In function 'void f()': a.cc:7:21: error: 'xxxxx' was not declared in this scope 7 | fcn(xxxxx); // comment | ^~~~~ For some reason, the horizontal position is greatly offset when -save-temps is enabled. This doesn't happen if the macro manipulation is commented out. The comment doesn't affect the problem, but I added it just to also point out that the underlined part (// c) is similarly colored red in the bad case. If there's no comment, the output looks like: a.cc: In function 'void f()': a.cc:7:21: error: 'xxxxx' was not declared in this scope 7 | fcn(xxxxx); | ^