public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
@ 2014-03-07 20:40 daniel.kruegler at googlemail dot com
  2014-11-18 11:35 ` [Bug c++/60437] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-03-07 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60437
           Summary: [C++11] Bogus "error: no matching function for call to
                    'X::X(<brace-enclosed initializer list>)'"
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com
                CC: daniel.kruegler at googlemail dot com
                CC: daniel.kruegler at googlemail dot com

Using current trunk
g++ (GCC) 4.9.0 20140305 (experimental)


g++ -c t.cc -std=c++11
t.cc: In function 'void f()':
t.cc:10:8: error: no matching function for call to 'X::X(<brace-enclosed
initializer list>)'
   X x{1};
        ^
t.cc:10:8: note: candidates are:
t.cc:6:3: note: X::X(std::initializer_list<int>)
   X(std::initializer_list<int> init = std::initializer_list<int>()){}
   ^
t.cc:6:3: note:   no known conversion for argument 1 from 'int' to
'std::initializer_list<int>'
t.cc:3:7: note: constexpr X::X(const X&)
 class X {
       ^
t.cc:3:7: note:   no known conversion for argument 1 from 'int' to 'const X&'
t.cc:3:7: note: constexpr X::X(X&&)
t.cc:3:7: note:   no known conversion for argument 1 from 'int' to 'X&&'


Code accepted by clang, and is correct (AFAICT):

#include <initializer_list>

class X {
 public:
  // X(std::initializer_list<int> init);  // OK
  X(std::initializer_list<int> init = std::initializer_list<int>()){}
};

void f(){
  X x{1};
}


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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
@ 2014-11-18 11:35 ` paolo.carlini at oracle dot com
  2014-11-18 12:32 ` manu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-18 11:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-18
     Ever confirmed|0                           |1


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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
  2014-11-18 11:35 ` [Bug c++/60437] " paolo.carlini at oracle dot com
@ 2014-11-18 12:32 ` manu at gcc dot gnu.org
  2014-11-18 13:23 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2014-11-18 12:32 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3791 bytes --]

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Paul Pluzhnikov from comment #0)
> Using current trunk
> g++ (GCC) 4.9.0 20140305 (experimental)
> 
> 
> g++ -c t.cc -std=c++11
> t.cc: In function 'void f()':
> t.cc:10:8: error: no matching function for call to 'X::X(<brace-enclosed
> initializer list>)'
>    X x{1};

Could we also print something better than <brace-enclosed initializer list>?

The linker prints:

undefined reference to `X::X(std::initializer_list<int>)'


Changing the testcase slightly gives:

test.C:12:8: error: no matching function for call to ‘X::X(<brace-enclosed
initializer list>)’
   X x{1};
        ^
test.C:12:8: note: candidates are:
test.C:7:3: note: X::X(std::initializer_list<Y>)
   X(std::initializer_list<Y> init);
   ^
test.C:7:3: note:   no known conversion for argument 1 from ‘int’ to
‘std::initializer_list<Y>’


Is it really trying to convert to 'std::initializer_list<Y>' from 'int' or from
'std::initializer_list<int>'?
>From gcc-bugs-return-467189-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 18 12:50:35 2014
Return-Path: <gcc-bugs-return-467189-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2762 invoked by alias); 18 Nov 2014 12:50: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 1904 invoked by uid 48); 18 Nov 2014 12:50:27 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/63843] [5 Regression] wrong code generation at -O1 and higher
Date: Tue, 18 Nov 2014 12:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status assigned_to attachments.created
Message-ID: <bug-63843-4-ymAGYtwGZ6@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63843-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63843-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: 2014-11/txt/msg01661.txt.bz2
Content-length: 571

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 34019
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4019&actioníit
gcc5-pr63843.patch

Untested fix.


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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
  2014-11-18 11:35 ` [Bug c++/60437] " paolo.carlini at oracle dot com
  2014-11-18 12:32 ` manu at gcc dot gnu.org
@ 2014-11-18 13:23 ` redi at gcc dot gnu.org
  2015-03-31  9:47 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-11-18 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #1)
> Could we also print something better than <brace-enclosed initializer list>?

Like what?

Clang's approach seems to be to issue the same diagnostic for ill-formed
initializations X(1) and X{1}, just saying "no matching constructor for
initialization of 'X'" which dodges the issue.

> Is it really trying to convert to 'std::initializer_list<Y>' from 'int' or
> from 'std::initializer_list<int>'?

From int.

{1} is not a std::initializer_list<int> (but can be converted to it)

A brace-enclosed initializer list is not the same as a std::initializer_list.
>From gcc-bugs-return-467196-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 18 13:34:45 2014
Return-Path: <gcc-bugs-return-467196-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22751 invoked by alias); 18 Nov 2014 13:34:44 -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 22707 invoked by uid 55); 18 Nov 2014 13:34:41 -0000
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58102] rejects valid initialization of constexpr object with mutable member
Date: Tue, 18 Nov 2014 13:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jason at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58102-4-GYo9nrpA2M@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58102-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58102-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: 2014-11/txt/msg01668.txt.bz2
Content-length: 614

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Nov 18 13:34:08 2014
New Revision: 217713

URL: https://gcc.gnu.org/viewcvs?rev!7713&root=gcc&view=rev
Log:
    PR c++/58102
    * typeck2.c (store_init_value): Set it.
    * cp-tree.h (CONSTRUCTOR_MUTABLE_POISON): New.
    * constexpr.c (cxx_eval_outermost_constant_expr): Check it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-mutable2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/typeck2.c


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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2014-11-18 13:23 ` redi at gcc dot gnu.org
@ 2015-03-31  9:47 ` paolo.carlini at oracle dot com
  2021-12-11  9:08 ` pinskia at gcc dot gnu.org
  2021-12-22 13:17 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-31  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david.d.kretzmer at gmail dot com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 65622 has been marked as a duplicate of this bug. ***


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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2015-03-31  9:47 ` paolo.carlini at oracle dot com
@ 2021-12-11  9:08 ` pinskia at gcc dot gnu.org
  2021-12-22 13:17 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-11  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.0
           Keywords|                            |needs-bisection

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems to be fixed on the trunk (for GCC 12).

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

* [Bug c++/60437] [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"
  2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2021-12-11  9:08 ` pinskia at gcc dot gnu.org
@ 2021-12-22 13:17 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-22 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed with r12-3555.

*** This bug has been marked as a duplicate of bug 102050 ***

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

end of thread, other threads:[~2021-12-22 13:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 20:40 [Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'" daniel.kruegler at googlemail dot com
2014-11-18 11:35 ` [Bug c++/60437] " paolo.carlini at oracle dot com
2014-11-18 12:32 ` manu at gcc dot gnu.org
2014-11-18 13:23 ` redi at gcc dot gnu.org
2015-03-31  9:47 ` paolo.carlini at oracle dot com
2021-12-11  9:08 ` pinskia at gcc dot gnu.org
2021-12-22 13:17 ` ppalka at gcc dot gnu.org

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).