public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
@ 2012-05-15 15:01 roucaries.bastien+bugs at gmail dot com
  2012-05-15 17:53 ` [Bug c++/53361] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: roucaries.bastien+bugs at gmail dot com @ 2012-05-15 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53361
           Summary: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed
                    initializer list>’ to ‘std::array<unsigned int, 3ul>’
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: roucaries.bastien+bugs@gmail.com


Fail to compile:

#include <array>

void function(std::array<unsigned int,3> a)
{
}

int main()
{
    // ok
  std::array<unsigned int,3> vec {0, 0, 0};

    // error: could not convert '{"hello", "world", "test"}' to
'std::vector...'
  function({0,0,0});
}

--------------------
8.5/14,16:

    The initialization that occurs in the form

    T x = a;

    as well as in argument passing, function return, throwing an exception
(15.1), handling an exception (15.3), and aggregate member initialization
(8.5.1) is called copy-initialization.
    .
    .
    The semantics of initializers are as follows[...]: If the initializer is a
braced-init-list, the object is list-initialized (8.5.4).

So it seems a bug.

bastien


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
@ 2012-05-15 17:53 ` pinskia at gcc dot gnu.org
  2012-05-21 15:47 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-05-15 17:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-05-15 17:48:58 UTC ---
Works on the trunk for me ...


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
  2012-05-15 17:53 ` [Bug c++/53361] " pinskia at gcc dot gnu.org
@ 2012-05-21 15:47 ` paolo.carlini at oracle dot com
  2012-05-21 21:36 ` roucaries.bastien+bugs at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-21 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2012-05-21
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-21 15:36:15 UTC ---
For me, it works everywhere, 4.7.0, 4.6.2 and current 4.7 branch included.
Thus, let's ask submitter to double check or we have to close this as
WORKSFORME.


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
  2012-05-15 17:53 ` [Bug c++/53361] " pinskia at gcc dot gnu.org
  2012-05-21 15:47 ` paolo.carlini at oracle dot com
@ 2012-05-21 21:36 ` roucaries.bastien+bugs at gmail dot com
  2012-05-21 21:38 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: roucaries.bastien+bugs at gmail dot com @ 2012-05-21 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Bastien ROUCARIES <roucaries.bastien+bugs at gmail dot com> 2012-05-21 21:19:35 UTC ---
bastien@bastien-debian:/tmp$ cat test.c
#include <array>

void function(std::array<unsigned int,3> a)
{
}

int main()
{
    // ok
std::array<unsigned int,3> vec {0, 0, 0};

// error: could not convert '{"hello", "world", "test"}' to
//'std::vector...'
function({0,0,0});
}
bastien@bastien-debian:/tmp$ g++-4.7 -std=c++11 test.c 
test.c: In function ‘int main()’:
test.c:14:17: error: could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed
initializer list>’ to ‘std::array<unsigned int, 3ul>’
bastien@bastien-debian:/tmp$ g++-4.7 --version
g++-4.7 (Debian 4.7.0-7) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


So it does not work under debian testing of the day (upgraded today)


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (2 preceding siblings ...)
  2012-05-21 21:36 ` roucaries.bastien+bugs at gmail dot com
@ 2012-05-21 21:38 ` paolo.carlini at oracle dot com
  2012-05-21 23:44 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-21 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-21 21:36:10 UTC ---
Oops, you are right, now I can reproduce, no idea what I was doing earlier
today. Sorry.

In any case, I can confirm what Andrew said, I cannot reproduce with mainline
and, AFAICS, this isn't a regression, thus I'm going to add the testcase to the
testsuite and close the PR as fixed.


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (3 preceding siblings ...)
  2012-05-21 21:38 ` paolo.carlini at oracle dot com
@ 2012-05-21 23:44 ` paolo.carlini at oracle dot com
  2012-05-21 23:45 ` paolo at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-21 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-21 21:50:33 UTC ---
Ah, I figured out what misled me: I added curly brackets to avoid
-Wmissing-braces warnings, ie, function({{0, 0, 0}}), and like this not only
the snippet doesn't trigger warnings, is actually accepted everywhere ;)


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (4 preceding siblings ...)
  2012-05-21 23:44 ` paolo.carlini at oracle dot com
@ 2012-05-21 23:45 ` paolo at gcc dot gnu.org
  2012-05-22  0:09 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-21 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-05-21 22:18:05 UTC ---
Author: paolo
Date: Mon May 21 22:17:54 2012
New Revision: 187746

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187746
Log:
2012-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53361
    * testsuite/23_containers/array/cons/53361.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/array/cons/53361.cc
Modified:
    trunk/libstdc++-v3/ChangeLog


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (5 preceding siblings ...)
  2012-05-21 23:45 ` paolo at gcc dot gnu.org
@ 2012-05-22  0:09 ` paolo.carlini at oracle dot com
  2014-07-22  3:23 ` nightstrike at gmail dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-22  0:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.8.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-21 22:19:13 UTC ---
Closing.


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (6 preceding siblings ...)
  2012-05-22  0:09 ` paolo.carlini at oracle dot com
@ 2014-07-22  3:23 ` nightstrike at gmail dot com
  2014-07-22  5:32 ` pinskia at gcc dot gnu.org
  2014-07-22  5:34 ` nightstrike at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: nightstrike at gmail dot com @ 2014-07-22  3:23 UTC (permalink / raw)
  To: gcc-bugs

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

nightstrike <nightstrike at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nightstrike at gmail dot com

--- Comment #8 from nightstrike <nightstrike at gmail dot com> ---
This SO post claims that GCC is in error:

http://stackoverflow.com/questions/8192185/using-stdarray-with-initialization-lists


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (7 preceding siblings ...)
  2014-07-22  3:23 ` nightstrike at gmail dot com
@ 2014-07-22  5:32 ` pinskia at gcc dot gnu.org
  2014-07-22  5:34 ` nightstrike at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-07-22  5:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to nightstrike from comment #8)
> This SO post claims that GCC is in error:


Yes and it was fixed in 4.8.


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

* [Bug c++/53361] Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’
  2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
                   ` (8 preceding siblings ...)
  2014-07-22  5:32 ` pinskia at gcc dot gnu.org
@ 2014-07-22  5:34 ` nightstrike at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: nightstrike at gmail dot com @ 2014-07-22  5:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from nightstrike <nightstrike at gmail dot com> ---
Oh, strange.  I thought I was still experiencing this on 4.8.2.  I'll check
again.  Sorry for the noise.


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

end of thread, other threads:[~2014-07-22  5:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-15 15:01 [Bug c++/53361] New: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<unsigned int, 3ul>’ roucaries.bastien+bugs at gmail dot com
2012-05-15 17:53 ` [Bug c++/53361] " pinskia at gcc dot gnu.org
2012-05-21 15:47 ` paolo.carlini at oracle dot com
2012-05-21 21:36 ` roucaries.bastien+bugs at gmail dot com
2012-05-21 21:38 ` paolo.carlini at oracle dot com
2012-05-21 23:44 ` paolo.carlini at oracle dot com
2012-05-21 23:45 ` paolo at gcc dot gnu.org
2012-05-22  0:09 ` paolo.carlini at oracle dot com
2014-07-22  3:23 ` nightstrike at gmail dot com
2014-07-22  5:32 ` pinskia at gcc dot gnu.org
2014-07-22  5:34 ` nightstrike at gmail 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).