Bug 80415 - [7 Regression] bogus "invalid initialization of reference" error
Summary: [7 Regression] bogus "invalid initialization of reference" error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0.1
: P1 normal
Target Milestone: 7.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2017-04-13 06:15 UTC by Markus Trippelsdorf
Modified: 2018-10-28 17:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.4.0, 6.3.0
Known to fail: 7.0
Last reconfirmed: 2017-04-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2017-04-13 06:15:00 UTC
LLVM trunk doesn't build anymore with gcc-7:

 % cat Arg.ii
struct A {
  A(int, int, const int (&)[0] = {});
};
A fn1() { return {0, 0}; }


 % g++ -c Arg.ii
Arg.ii: In function ‘A fn1()’:
Arg.ii:4:23: error: invalid initialization of reference of type ‘const int (&)[0]’ from expression of type ‘const int [0]’
 A fn1() { return {0, 0}; }
                       ^
Arg.ii:2:3: note: in passing argument 3 of ‘A::A(int, int, const int (&)[0])’
   A(int, int, const int (&)[0] = {});
   ^
Comment 1 Markus Trippelsdorf 2017-04-13 06:46:47 UTC
Started with r240819:

commit f3406a4b75137336c1b9d569d7602dd169cdb2ee
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Oct 5 22:58:55 2016 +0000

            PR c++/54293 - binding reference to member of temporary
Comment 2 Jason Merrill 2017-04-17 19:39:33 UTC
Author: jason
Date: Mon Apr 17 19:39:00 2017
New Revision: 246954

URL: https://gcc.gnu.org/viewcvs?rev=246954&root=gcc&view=rev
Log:
	PR c++/80415 - wrong error with default arg and array reference.

	* tree.c (lvalue_kind): Return clk_class for an array prvalue.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist-array5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/tree.c
Comment 3 Jason Merrill 2017-04-17 20:01:07 UTC
Fixed.