public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/58687] New: "#line __LINE__ ..." changes subsequent line numbers
@ 2013-10-11  3:47 mtewoodbury at gmail dot com
  2013-10-23  7:16 ` [Bug preprocessor/58687] " mtewoodbury at gmail dot com
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: mtewoodbury at gmail dot com @ 2013-10-11  3:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58687
           Summary: "#line __LINE__ ..." changes subsequent line numbers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mtewoodbury at gmail dot com

A preprocessor directive of the form '#line __LINE__ ..." should NOT change the
line number.  That is '__LINE__' should evaluate to the number of the NEXT line
in this context.

If you read the standards carefully, __LINE__ should have a value equal to the
number of 'new line' characters seen by the phaee 1 translation plus one WHEN
THE SUBSTITUTION OCCURS (unless modified by previous #line directives).

When the subsituyion occurs is controlled by the parsing done in phase 4 of
translation.  Specifically, subsitution in preprocessing directives occure when
the specific form of the directive has been  formally identified AND that form
calls for <pp_token> aubstitution.  The form in this case is:

    '#' 'line' <pp_token>+ <new_line>

Note that the terminating <new line> token has to have been seen BEFORE the
form is identifiad.  That means __LINE__ will normally have the line number of
the NEXT line in the file when the substitution occurs.  FURTHER NOTE that any
<new line> tokens in comments will also have been counted when the substiturion
occurs.

What is apparently happening instead is that the substitution is being made
BEFORE the particular form of the '#line' directive has been completely and
formally identified.  In other wordds you have folded the translation phases
togeather and botched up the carefully structured procedure with its
intentional delays in substitution set forth in the standard.


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

end of thread, other threads:[~2013-11-30  0:04 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11  3:47 [Bug preprocessor/58687] New: "#line __LINE__ ..." changes subsequent line numbers mtewoodbury at gmail dot com
2013-10-23  7:16 ` [Bug preprocessor/58687] " mtewoodbury at gmail dot com
2013-10-25 19:01 ` mtewoodbury at gmail dot com
2013-10-25 22:56 ` mtewoodbury at gmail dot com
2013-10-26 13:39 ` mtewoodbury at gmail dot com
2013-10-26 21:15 ` pinskia at gcc dot gnu.org
2013-10-27 13:59 ` mtewoodbury at gmail dot com
2013-10-28 17:51 ` mtewoodbury at gmail dot com
2013-10-28 18:53 ` joseph at codesourcery dot com
2013-10-30  7:39 ` mtewoodbury at gmail dot com
2013-10-30 15:08 ` manu at gcc dot gnu.org
2013-10-30 17:59 ` mtewoodbury at gmail dot com
2013-10-30 18:13 ` joseph at codesourcery dot com
2013-10-30 19:43 ` mtewoodbury at gmail dot com
2013-10-31 18:00 ` mtewoodbury at gmail dot com
2013-11-04 14:14 ` mtewoodbury at gmail dot com
2013-11-04 18:18 ` joseph at codesourcery dot com
2013-11-19 16:08 ` mtewoodbury at gmail dot com
2013-11-19 16:37 ` joseph at codesourcery dot com
2013-11-28 22:52 ` jsm28 at gcc dot gnu.org
2013-11-29  4:52 ` mtewoodbury at gmail dot com
2013-11-29 16:57 ` joseph at codesourcery dot com
2013-11-29 22:49 ` mtewoodbury at gmail dot com
2013-11-30  0:04 ` joseph at codesourcery dot com

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).