public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53494] New: initializer lists in array type
@ 2012-05-26  9:40 marcus-yass at ihug dot co.nz
  2012-05-26 10:10 ` [Bug c++/53494] " paolo.carlini at oracle dot com
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: marcus-yass at ihug dot co.nz @ 2012-05-26  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53494
           Summary: initializer lists in array type
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marcus-yass@ihug.co.nz


Created attachment 27502
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27502
preprocessed source for failed compile

g++-4.7 -std=c++11 1.cpp -o e1

1.cpp:
#include <iostream>
#include <utility>
#include <array>
using namespace std;

array<pair<string, unsigned> const, 1> const matchSynonyms{ {"smile",1} };

int main(int argc, char **argv){
    cout<<"success"<<endl;
}

leads to output:

"
‘
/home/mako/programming/cing/1.cpp:6: confused by earlier errors, bailing out
Preprocessed source stored into /tmp/ccTX9zYB.out file, please attach this to
your bugreport.
"


I also get problems when I try to use a vector instead of a pair, but the
errors are a lot longer and confusing and it's harder to rule out user error.


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

* [Bug c++/53494] initializer lists in array type
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
@ 2012-05-26 10:10 ` paolo.carlini at oracle dot com
  2012-05-26 14:54 ` redi at gcc dot gnu.org
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-26 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-26 09:40:37 UTC ---
In any case a good workaround is using matchSynonyms{{ {"smile",1} }}


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

* [Bug c++/53494] initializer lists in array type
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
  2012-05-26 10:10 ` [Bug c++/53494] " paolo.carlini at oracle dot com
@ 2012-05-26 14:54 ` redi at gcc dot gnu.org
  2012-05-26 15:16 ` [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list redi at gcc dot gnu.org
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-26 14:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery,
                   |                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-26
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-26 14:50:36 UTC ---
#include <array>
#include <utility>

using std::array;
using std::pair;

struct string
{
  string(const char*) { }
};

array<pair<string, unsigned> const, 1> const matchSynonyms{ {"smile",1} };


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
  2012-05-26 10:10 ` [Bug c++/53494] " paolo.carlini at oracle dot com
  2012-05-26 14:54 ` redi at gcc dot gnu.org
@ 2012-05-26 15:16 ` redi at gcc dot gnu.org
  2012-05-26 17:06 ` paolo.carlini at oracle dot com
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-26 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.6.3
            Summary|initializer lists in array  |[4.7/4.8 Regression] ICE
                   |type                        |with invalid initializer
                   |                            |list

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-26 15:08:59 UTC ---
further reduced

#include <utility>
using std::pair;

template<typename T>
struct array
{
  typedef T value_type;
  value_type data[1];
};

struct string
{
  string(const char*) { }
};

array<pair<string, unsigned> const> const matchSynonyms{ {"smile",1} };

4.6 correctly rejects it:

a.cc:16:70: error: too many initializers for 'array<const std::pair<string,
unsigned int> >::value_type [1] {aka const std::pair<string, unsigned int>
[1]}'
a.cc:16:70: error: could not convert '(const char*)"smile"' from 'const char*'
to 'array<const std::pair<string, unsigned int> >::value_type {aka const
std::pair<string, unsigned int>}'

4.7 gives:

'
a.cc:16: confused by earlier errors, bailing out

and 4.8 gives:

'
in strip_typedefs, at cp/tree.c:1196
 array<pair<string, unsigned> const> const matchSynonyms{ {"smile",1} };
                                                                      ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (2 preceding siblings ...)
  2012-05-26 15:16 ` [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list redi at gcc dot gnu.org
@ 2012-05-26 17:06 ` paolo.carlini at oracle dot com
  2012-05-26 20:32 ` marcus-yass at ihug dot co.nz
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-26 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-26 15:16:29 UTC ---
And since it's actually invalid should be pretty easy to fix, the ICE is
happening in a gcc_assert where alignment is handled, nothing to do.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (3 preceding siblings ...)
  2012-05-26 17:06 ` paolo.carlini at oracle dot com
@ 2012-05-26 20:32 ` marcus-yass at ihug dot co.nz
  2012-05-26 21:13 ` paolo.carlini at oracle dot com
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: marcus-yass at ihug dot co.nz @ 2012-05-26 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from mako <marcus-yass at ihug dot co.nz> 2012-05-26 20:31:39 UTC ---
Would someone please explain to me why that compile error is considered
correct? It tells me nothing sensible.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (4 preceding siblings ...)
  2012-05-26 20:32 ` marcus-yass at ihug dot co.nz
@ 2012-05-26 21:13 ` paolo.carlini at oracle dot com
  2012-05-26 21:47 ` marcus-yass at ihug dot co.nz
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-26 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-26 21:00:21 UTC ---
Who said correct?!?


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (5 preceding siblings ...)
  2012-05-26 21:13 ` paolo.carlini at oracle dot com
@ 2012-05-26 21:47 ` marcus-yass at ihug dot co.nz
  2012-05-28 16:17 ` paolo.carlini at oracle dot com
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: marcus-yass at ihug dot co.nz @ 2012-05-26 21:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from mako <marcus-yass at ihug dot co.nz> 2012-05-26 21:41:57 UTC ---
Uh, Johnathan said "4.6 correctly rejects it:", however 4.6's rejection message
appears every bit as useless as 4.7's, perhaps more so, because it
misattributes the error. If that's the correct way to reject it... Compiler
logic is beyond me.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (6 preceding siblings ...)
  2012-05-26 21:47 ` marcus-yass at ihug dot co.nz
@ 2012-05-28 16:17 ` paolo.carlini at oracle dot com
  2012-05-28 16:25 ` redi at gcc dot gnu.org
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-28 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-28 16:11:29 UTC ---
"correctly rejects it" in general means "per the ISO C++ Standard, which we are
implementing, the testcase is invalid with diagnostics required, thus the
compiler is right in rejecting it", thus it doesn't have anything to do with
providing a better, more informative, error message. Just to clarify.

And indeed, I think Jon's analysis is correct. Maybe Daniel has something to
add.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (7 preceding siblings ...)
  2012-05-28 16:17 ` paolo.carlini at oracle dot com
@ 2012-05-28 16:25 ` redi at gcc dot gnu.org
  2012-05-28 16:27 ` redi at gcc dot gnu.org
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-28 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-28 16:21:24 UTC ---
4.6 gets the error right, what you're doing is equivalent to:

struct pair
{
  pair(const char*, int) { }
};

struct array
{
  pair data[1];
};

array a { { "smile", 1 } };

And that isn't valid. The error 4.6 gives for that is:

t.cc:11:26: error: too many initializers for 'pair [1]'
t.cc:11:26: error: could not convert '(const char*)"smile"' from 'const char*'
to 'pair'

Which is very similar to the error 4.6 gives for your original code, except he
types in your original are more complicated because they involve templates and
typedefs.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (8 preceding siblings ...)
  2012-05-28 16:25 ` redi at gcc dot gnu.org
@ 2012-05-28 16:27 ` redi at gcc dot gnu.org
  2012-05-28 16:32 ` paolo.carlini at oracle dot com
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-28 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-28 16:25:12 UTC ---
The code:
   array a { { "smile", 1 } };

Attempts to initialize array with { { "smile", 1 } }

which attempts to initialize pair[2] with { "smile", 1 }

which fairly obviously attemptes to initialize the first pair with "smile", and
the second pair with 1, neither of which is valid.

Why do you think the error is misattributed?


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (9 preceding siblings ...)
  2012-05-28 16:27 ` redi at gcc dot gnu.org
@ 2012-05-28 16:32 ` paolo.carlini at oracle dot com
  2012-05-28 16:41 ` paolo.carlini at oracle dot com
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-28 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com

--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-28 16:27:23 UTC ---
I will look into the ICE. Not immediately, however.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (10 preceding siblings ...)
  2012-05-28 16:32 ` paolo.carlini at oracle dot com
@ 2012-05-28 16:41 ` paolo.carlini at oracle dot com
  2012-05-28 21:42 ` marcus-yass at ihug dot co.nz
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-28 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-28 16:32:23 UTC ---
With checking disabled the error message comes out fine, thus the issue isn't
really urgent.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (11 preceding siblings ...)
  2012-05-28 16:41 ` paolo.carlini at oracle dot com
@ 2012-05-28 21:42 ` marcus-yass at ihug dot co.nz
  2012-05-29 10:29 ` rguenth at gcc dot gnu.org
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: marcus-yass at ihug dot co.nz @ 2012-05-28 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from mako <marcus-yass at ihug dot co.nz> 2012-05-28 21:04:25 UTC ---
Am I interpreting correctly that double braces are /required/ for std::array
init lists but only when the subtype has has a multivariable initializer too?

..????


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (12 preceding siblings ...)
  2012-05-28 21:42 ` marcus-yass at ihug dot co.nz
@ 2012-05-29 10:29 ` rguenth at gcc dot gnu.org
  2012-05-29 14:22 ` rguenth at gcc dot gnu.org
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-05-29 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.1


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (13 preceding siblings ...)
  2012-05-29 10:29 ` rguenth at gcc dot gnu.org
@ 2012-05-29 14:22 ` rguenth at gcc dot gnu.org
  2012-05-29 22:14 ` daniel.kruegler at googlemail dot com
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-05-29 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (14 preceding siblings ...)
  2012-05-29 14:22 ` rguenth at gcc dot gnu.org
@ 2012-05-29 22:14 ` daniel.kruegler at googlemail dot com
  2012-05-29 22:33 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-29 22:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-29 21:16:57 UTC ---
(In reply to comment #13)
> Am I interpreting correctly that double braces are /required/ for std::array
> init lists but only when the subtype has has a multivariable initializer too?

I must agree that the compiler behaviour does not look correct to me. Initially
I thought that the reason is due to the fact, that brace-elision does not apply
here, but then I noticed that this code does not compile either:

struct pair
{
  pair(const char*, int) { }
};

struct array_p
{
  pair data[1];
};

array_p a  = { { "smile", 1 } };

Here we have definitively brace elision in action, but I get the same error as
from Jonathan's example. My impression is that the compiler incorrectly does
not see the brace-elision case here.

Here is an example that works (with an expected [-Wmissing-braces] warning):

struct string
{
  string(const char*) { }
};

struct array_s
{
  string data[1];
};

array_s b{ "smile" };

From this I see that gcc already implements

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1270

so I must conclude that the compiler should also accept the original example.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (15 preceding siblings ...)
  2012-05-29 22:14 ` daniel.kruegler at googlemail dot com
@ 2012-05-29 22:33 ` paolo.carlini at oracle dot com
  2012-05-29 23:15 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-29 22:33 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
                   |com                         |gnu.org


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (16 preceding siblings ...)
  2012-05-29 22:33 ` paolo.carlini at oracle dot com
@ 2012-05-29 23:15 ` paolo.carlini at oracle dot com
  2012-05-29 23:36 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-29 23:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-29 23:00:34 UTC ---
Thanks Daniel. Let's see if Jon agrees with your analysis. To be honest, at
first, when I figured out the workaround, it seemed a brace-elision issue to me
too, but then I haven't been able to spend enough time on the details of the
issue, unfortunately.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (17 preceding siblings ...)
  2012-05-29 23:15 ` paolo.carlini at oracle dot com
@ 2012-05-29 23:36 ` redi at gcc dot gnu.org
  2012-05-29 23:45 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-29 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-29 23:34:14 UTC ---
(In reply to comment #14)
> struct pair
> {
>   pair(const char*, int) { }
> };
> 
> struct array_p
> {
>   pair data[1];
> };
> 
> array_p a  = { { "smile", 1 } };
> 
> Here we have definitively brace elision in action, but I get the same error as
> from Jonathan's example.


"If the initializer-list begins with a left brace,"

which it does

"then the succeeding comma-separated list of initializer-clauses initializes
the members of a subaggregate;"

I read that to mean that { "smile", 1 } initializes the pair[1]

"it is erroneous for there to be more initializer-clauses than members."

There is only one member of pair[1] but two initializer-clauses.

So I think the error is required, but Daniel is usually right about such things
so I'm not certain :)


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (18 preceding siblings ...)
  2012-05-29 23:36 ` redi at gcc dot gnu.org
@ 2012-05-29 23:45 ` redi at gcc dot gnu.org
  2012-05-30  6:47 ` daniel.kruegler at googlemail dot com
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-29 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-29 23:36:02 UTC ---
clang version 3.2 (trunk 155804) also rejects it:

t.cc:11:18: error: no viable conversion from 'const char [6]' to 'pair'


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (19 preceding siblings ...)
  2012-05-29 23:45 ` redi at gcc dot gnu.org
@ 2012-05-30  6:47 ` daniel.kruegler at googlemail dot com
  2012-05-30  8:31 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-30  6:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-30 06:25:27 UTC ---
(In reply to comment #16)
> "If the initializer-list begins with a left brace,"
> 
> which it does
> 
> "then the succeeding comma-separated list of initializer-clauses initializes
> the members of a subaggregate;"
> 
> I read that to mean that { "smile", 1 } initializes the pair[1]
> 
> "it is erroneous for there to be more initializer-clauses than members."
> 
> There is only one member of pair[1] but two initializer-clauses.
> 
> So I think the error is required, but Daniel is usually right about such things
> so I'm not certain :)

Thanks Jon. I agree with you, the wording seems clear. This looks like a very
unfortunate language rule, because it leads to an inconsistency (from the
user-point), when comparing this with non-aggregate list-initialization as in
the following case:

std::initializer_list<std::pair<std::string, unsigned>> lp = { {"a", 1} };

which is well-formed. I would like to withdraw my concerns expressed in comment
14 so that there is no hindrance to close this issue - anything else seems to
belong to a discussion at another place.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (20 preceding siblings ...)
  2012-05-30  6:47 ` daniel.kruegler at googlemail dot com
@ 2012-05-30  8:31 ` redi at gcc dot gnu.org
  2012-05-30  9:12 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-30  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-30 08:17:07 UTC ---
(In reply to comment #13)
> Am I interpreting correctly that double braces are /required/ for std::array
> init lists but only when the subtype has has a multivariable initializer too?
> 
> ..????

Yes.  Double braces are always correct and always allowed, but you can omit
them if the result is unambiguous, e.g. array<int,3>{1,2,3} is equivalent to
array<int,3>{{1,2,3}}
But if the array's value_type is to be initialized with a
braced-initializer-list then you need a completely-braced initialization so
that the initializer-list for the value_type doesn't get interpreted as an
initializer for the value_type[N] array.

It still shouldn't crash the compiler though :)


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (21 preceding siblings ...)
  2012-05-30  8:31 ` redi at gcc dot gnu.org
@ 2012-05-30  9:12 ` paolo.carlini at oracle dot com
  2012-06-08  9:21 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-30  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com

--- Comment #20 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-30 08:54:39 UTC ---
Good, good, then let me fix the ICE.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (22 preceding siblings ...)
  2012-05-30  9:12 ` paolo.carlini at oracle dot com
@ 2012-06-08  9:21 ` paolo.carlini at oracle dot com
  2012-06-08  9:27 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-06-08  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-06-08 09:20:47 UTC ---
No includes:

template<typename T, typename U>
struct pair
{
  T first;
  U second;

  pair(const T&, const U&);
};

template<typename T>
struct array
{
  typedef T value_type;
  value_type data[1];
};

struct string
{
  string(const char*) { }
};

array<pair<string, unsigned> const> const matchSynonyms{ {"smile",1} };


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (23 preceding siblings ...)
  2012-06-08  9:21 ` paolo.carlini at oracle dot com
@ 2012-06-08  9:27 ` paolo.carlini at oracle dot com
  2012-06-14  8:19 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-06-08  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-06-08 09:27:34 UTC ---
A tad simpler:

template<typename T, typename U>
struct pair
{
  T first;
  U second;

  pair(const T&, const U&);
};

template<typename T>
struct array
{
  typedef T value_type;
  value_type data[1];
};

array<pair<int, int> const> matchSynonyms{ { 1, 1 } };


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (24 preceding siblings ...)
  2012-06-08  9:27 ` paolo.carlini at oracle dot com
@ 2012-06-14  8:19 ` rguenth at gcc dot gnu.org
  2012-08-06 11:58 ` paolo.carlini at oracle dot com
  2012-08-06 15:42 ` paolo.carlini at oracle dot com
  27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-14  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.1                       |4.7.2

--- Comment #23 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-14 08:18:38 UTC ---
GCC 4.7.1 is being released, adjusting target milestone.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (25 preceding siblings ...)
  2012-06-14  8:19 ` rguenth at gcc dot gnu.org
@ 2012-08-06 11:58 ` paolo.carlini at oracle dot com
  2012-08-06 15:42 ` paolo.carlini at oracle dot com
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-06 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwakely.gcc at gmail dot
                   |                            |com

--- Comment #24 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-06 11:57:56 UTC ---
Jon, can you help me double checking mainline? Apparently something changed and
I can't reproduce the ICE anymore.


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

* [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
  2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
                   ` (26 preceding siblings ...)
  2012-08-06 11:58 ` paolo.carlini at oracle dot com
@ 2012-08-06 15:42 ` paolo.carlini at oracle dot com
  27 siblings, 0 replies; 29+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-06 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
         AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
                   |com                         |gnu.org

--- Comment #25 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-06 15:42:10 UTC ---
Fixed by the patch which fixed c++/53989.


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

end of thread, other threads:[~2012-08-06 15:42 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-26  9:40 [Bug c++/53494] New: initializer lists in array type marcus-yass at ihug dot co.nz
2012-05-26 10:10 ` [Bug c++/53494] " paolo.carlini at oracle dot com
2012-05-26 14:54 ` redi at gcc dot gnu.org
2012-05-26 15:16 ` [Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list redi at gcc dot gnu.org
2012-05-26 17:06 ` paolo.carlini at oracle dot com
2012-05-26 20:32 ` marcus-yass at ihug dot co.nz
2012-05-26 21:13 ` paolo.carlini at oracle dot com
2012-05-26 21:47 ` marcus-yass at ihug dot co.nz
2012-05-28 16:17 ` paolo.carlini at oracle dot com
2012-05-28 16:25 ` redi at gcc dot gnu.org
2012-05-28 16:27 ` redi at gcc dot gnu.org
2012-05-28 16:32 ` paolo.carlini at oracle dot com
2012-05-28 16:41 ` paolo.carlini at oracle dot com
2012-05-28 21:42 ` marcus-yass at ihug dot co.nz
2012-05-29 10:29 ` rguenth at gcc dot gnu.org
2012-05-29 14:22 ` rguenth at gcc dot gnu.org
2012-05-29 22:14 ` daniel.kruegler at googlemail dot com
2012-05-29 22:33 ` paolo.carlini at oracle dot com
2012-05-29 23:15 ` paolo.carlini at oracle dot com
2012-05-29 23:36 ` redi at gcc dot gnu.org
2012-05-29 23:45 ` redi at gcc dot gnu.org
2012-05-30  6:47 ` daniel.kruegler at googlemail dot com
2012-05-30  8:31 ` redi at gcc dot gnu.org
2012-05-30  9:12 ` paolo.carlini at oracle dot com
2012-06-08  9:21 ` paolo.carlini at oracle dot com
2012-06-08  9:27 ` paolo.carlini at oracle dot com
2012-06-14  8:19 ` rguenth at gcc dot gnu.org
2012-08-06 11:58 ` paolo.carlini at oracle dot com
2012-08-06 15:42 ` paolo.carlini at oracle 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).