public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/67192] Backward-goto in loop can get wrong line number
Date: Tue, 18 Aug 2015 16:11:00 -0000	[thread overview]
Message-ID: <bug-67192-4-5VSenCsc2D@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67192-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67192

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #3)
> Created attachment 36203 [details]
> Patch
> 
> The issue seems to be in here in c_parser_for_statement:
> 
>   warn_for_misleading_indentation (for_loc, body_loc,
> 				   c_parser_peek_token (parser)->location,
> 				   c_parser_peek_token (parser)->type,
> 				   "for");
> 
> where the calls to c_parser_peek_token can lead to input_location being
> changed.
> 
> The attached patch (barely tested) restores the previous location for the
> "goto" by saving and restoring input_location.

The given patch was on top of r223098
(e5f01cbafce70120afe8f73df099dcc2796adcd7), but doesn't apply to trunk; r226477
(9255be07ea1ac0e2f2991aa11cfc892474add3b2) changed the internal API for this,
so the save/restore of input_location would need updating for this.
>From gcc-bugs-return-495107-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Aug 18 16:22:36 2015
Return-Path: <gcc-bugs-return-495107-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24050 invoked by alias); 18 Aug 2015 16:22:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 23995 invoked by uid 48); 18 Aug 2015 16:22:32 -0000
From: "cubbi at cubbi dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67259] New: list-initialization of a reference fails to initialize char array from string literal
Date: Tue, 18 Aug 2015 16:22:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: cubbi at cubbi dot org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
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 target_milestone
Message-ID: <bug-67259-4@http.gcc.gnu.org/bugzilla/>
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: 2015-08/txt/msg01249.txt.bz2
Content-length: 1223

https://gcc.gnu.org/bugzilla/show_bug.cgi?idg259

            Bug ID: 67259
           Summary: list-initialization of a reference fails to initialize
                    char array from string literal
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cubbi at cubbi dot org
  Target Milestone: ---

The following is accepted by clang, intel, and msvc, but fails to compile with
gcc (HEAD 6.0.0 20150817)

struct agg { char str[20]; };
int main() {
    const agg& r {"foo"};
}

with the following diagnostic:

prog.cc: In function 'int main()':
prog.cc:3:24: error: invalid initialization of reference of type 'const agg&'
from expression of type '<brace-enclosed initializer list>'
     const agg& r {"foo"};
                        ^
prog.cc:3:16: warning: unused variable 'r' [-Wunused-variable]
     const agg& r {"foo"};
                ^
(this also prevents agg x; x = { "foo" };)

it appears to be one of the consequences of the changes to list initialization
recently made by http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1467


  parent reply	other threads:[~2015-08-18 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 14:56 [Bug debug/67192] New: " arnez at linux dot vnet.ibm.com
2015-08-17 15:30 ` [Bug debug/67192] " arnez at linux dot vnet.ibm.com
2015-08-18 15:23 ` dmalcolm at gcc dot gnu.org
2015-08-18 15:52 ` dmalcolm at gcc dot gnu.org
2015-08-18 16:05 ` dmalcolm at gcc dot gnu.org
2015-08-18 16:11 ` dmalcolm at gcc dot gnu.org [this message]
2015-08-18 16:23 ` dmalcolm at gcc dot gnu.org
2015-08-18 17:16 ` arnez at linux dot vnet.ibm.com
2015-08-18 19:56 ` manu at gcc dot gnu.org
2015-08-18 20:07 ` ppalka at gcc dot gnu.org
2015-09-11 18:17 ` arnez at linux dot vnet.ibm.com
2015-09-23  1:31 ` ppalka at gcc dot gnu.org
2015-09-23  7:02 ` manu at gcc dot gnu.org
2015-10-08 16:40 ` [Bug debug/67192] [6 Regression] " manu at gcc dot gnu.org
2015-10-09 10:49 ` arnez at linux dot vnet.ibm.com
2015-10-09 10:58 ` manu at gcc dot gnu.org
2015-10-09 11:11 ` manu at gcc dot gnu.org
2015-10-12 14:32 ` arnez at linux dot vnet.ibm.com
2015-10-23 15:32 ` arnez at linux dot vnet.ibm.com

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-67192-4-5VSenCsc2D@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: link
Be 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).