public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/58687] "#line __LINE__ ..." changes subsequent line numbers Date: Sat, 30 Nov 2013 00:04:00 -0000 [thread overview] Message-ID: <bug-58687-4-4fxJt6UseT@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-58687-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58687 --- Comment #24 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- On Fri, 29 Nov 2013, mtewoodbury at gmail dot com wrote: > > The question is not when it takes place, it's what the "current token" is > > when it takes place, because "line number" is defined in terms of the > > current token rather than the time of expansion. > > If that is what they meant, they would have said something like "the line > number when the __LINE__ token is seen', but they say 'current line' and > define 'current line' elsewhere. > > > I think the current token is clearly __LINE__ on the #line directive. > > But the standard says 'current line'. It says nothing about 'current > token' in this context. The only uses of the phrase "current line" in C11 are in subclause 5.2.2 Character display semantics; I suppose you mean "current source line". What 6.10.4 says is "The line number of the current source line is one greater than the number of new-line characters read or introduced in translation phase 1 (5.1.1.2) while processing the source file to the current token.", and 6.10.8.1 says __LINE__ expands to "The presumed line number (within the current source file) of the current source line (an integer constant).". "line number of the current source line" is defined as a whole in terms of the "current token"; "current source line" is not something that's defined or meaningful by itself. Not processing until expansion occurs, not processing until the form of a syntax construct is identified, but processing to the current token, which is surely __LINE__ in this case. > You are arguing about macro expansion again. Macro expansion is an > immediate process and, as you pointed out, somewhat ambiguous. The case > being argued here is the expansion of <pp-tokens> in directives where their > expansion is delayed until after the form of the directive has been > established. Expansion of those tokens is just one instance of macro expansion. Exactly the same ambiguity occurs in the case of #line macro \ ( \ __LINE__ \ ) (is "macro", "__LINE__" or ")" the current token?) and does not occur in the case of plain #line __LINE__ > So everyone else is wrong? Implementations not treating #line __LINE__ as giving the next line the same line number as the #line directive are either using a very strained interpretation of the standard, or haven't considered the issue and have achieved their results by accident. > Realty, you should consider what the users of the language need to be able > to do. There is need for an easy way to change __FILE__ without messing > up the line number sequence. '#line __LINE__ ...' is fairly obviously that > mechanism and the extra verbiage in the standard is a fairly obvious > attempt to accommodate that need. I don't believe the standard makes any such attempt to accommodate such a (marginal) need; the wording is simply the most natural way to describe the possible forms of #line directive within the style used by the standard. Note there are no examples in the standard to indicate any particular intent regarding corner cases of #line or __LINE__. If you disagree with an implementor (or conformance testsuite vendor, etc.) about the interpretation of the standard, the next step is to file a DR with WG14. You can send proposed DRs directly to the convenor - most go that way - you don't need to go via your National Body (although WG14 has no obligation to accept a document as a DR unless the formal NB process is followed).
prev parent reply other threads:[~2013-11-30 0:04 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-10-11 3:47 [Bug preprocessor/58687] New: " 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 message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-58687-4-4fxJt6UseT@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).