public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/17970] New: Preprocessor seems not to create newlines for all # <linenumber> debug stmts in nested macros
@ 2004-10-13  7:53 fingon at iki dot fi
  2004-10-13 11:43 ` [Bug preprocessor/17970] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: fingon at iki dot fi @ 2004-10-13  7:53 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug preprocessor/17970] Preprocessor seems not to create newlines for all # <linenumber> debug stmts in nested macros
  2004-10-13  7:53 [Bug preprocessor/17970] New: Preprocessor seems not to create newlines for all # <linenumber> debug stmts in nested macros fingon at iki dot fi
@ 2004-10-13 11:43 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-13 11:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-13 11:43 -------
Not a bug at all, preprocessor directives in a macro invocation is undefined.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17970


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-13 11:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-13  7:53 [Bug preprocessor/17970] New: Preprocessor seems not to create newlines for all # <linenumber> debug stmts in nested macros fingon at iki dot fi
2004-10-13 11:43 ` [Bug preprocessor/17970] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).