From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7799 invoked by alias); 11 Oct 2013 03:47:39 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7762 invoked by uid 48); 11 Oct 2013 03:47:35 -0000 From: "mtewoodbury at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/58687] New: "#line __LINE__ ..." changes subsequent line numbers Date: Fri, 11 Oct 2013 03:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mtewoodbury at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00611.txt.bz2 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 aubstitution. The form in this case is: '#' 'line' + Note that the terminating 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 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.