This report applies (at least) to these: g++ (GCC) 3.3.5 (Debian 1:3.3.5-1) g++-3.4 (GCC) 3.4.2 (Debian 3.4.2-2)
code fragment (from expanded code, censored to protect the innocent): #line 54 CQ_DEBUG(5, << "xxx: " << *v << " (@ " #line 54 << v.get() << ")"); #line 54 The contents of CQ_DEBUG are not interesting, and it's valid (fairly small) macro. However, the output of preprocessing is strange: # 54 "XXX.cpp" do { if (cq_debug_enabled(5, debug_module_name, debug_file_name, 54)) { ostringstream temp; temp << "xxx: " << *v << " (@ " << v.get() << ")"; temp << '\0'; cq_debug_output(5, debug_module_name, cq_debug_clean_file_name(debug_file_name), 54, temp.str().c_str()); } } while(0);# 54 "XXX.cpp" I hope this cut-n-paste did not screw it up, but basically there's missing newline from the transformed #line precompiler output (# 54 ..). Strange thing is, this happens only when doing preprocessing-only (g++ -E). If I run whole g++ -c foo.cpp -o foo.o, things work beautifully. Note that this works correctly if I change the macro to one line: #line 54 CQ_DEBUG(5, << "xxx: " << *v << " (@ " << v.get() << ")"); #line 54 Because #lines within macros are bit questionable to start with, I'm not quite sure if this is a bug, but because it works with normal 'g++', I should say it should work with 'g++ -E' too..? I did not have the time (work, work).. to actually test with latest snapshot, sorry (and apparently Debian's latest is 2 months old so I didn't bother). -- Summary: Preprocessor seems not to create newlines for all # <linenumber> debug stmts in nested macros Product: gcc Version: 3.3.5 Status: UNCONFIRMED Severity: normal Priority: P2 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: fingon at iki dot fi CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: linux-x86-debian-unstable http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17970