public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64418] New: User-defined conversion not properly suppressed in certain cases of list-initialisation
@ 2014-12-27 16:00 momchil.velikov at gmail dot com
  2014-12-27 20:11 ` [Bug c++/64418] " redi at gcc dot gnu.org
  2014-12-27 23:47 ` jason at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: momchil.velikov at gmail dot com @ 2014-12-27 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64418
           Summary: User-defined conversion not properly suppressed in
                    certain cases of list-initialisation
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: momchil.velikov at gmail dot com

Consider the example:
--- 8< ------
struct C {
  C(const C &);
};

struct X {
  operator C() const;
};

C a{X()};

--- 8< ------

This program is successfully compiled. However, I believe this is an
erroneous behavior.

The variable "a" is initialised by direct list-initialization
according to 8.5.4. [dcl.init.list] #3 and 13.3.1.7 [over.match.list].
As the class C does not have an initializer-list ctor, all the
constructors of C are tried with the elements of the initializer list
as arguments.

GCC tries and in fact finds a user-defined conversion sequence from X
to the first parameter of the C's copy-ctor.

However, according to 13.3.3.1 [over.best.ics] #4, 

"[...] when considering the argument of a constructor [...] that is a
candidate by [...] by 13.3.1.7 [...] or when the initializer list has
exactly one element and a conversion to some class X or reference to
(possibly cv-qualified) X is considered for the first parameter of a
constructor of X [...] only standard conversion sequences and ellipsis
conversion sequences are considered.

Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51553 is related to this one.


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

* [Bug c++/64418] User-defined conversion not properly suppressed in certain cases of list-initialisation
  2014-12-27 16:00 [Bug c++/64418] New: User-defined conversion not properly suppressed in certain cases of list-initialisation momchil.velikov at gmail dot com
@ 2014-12-27 20:11 ` redi at gcc dot gnu.org
  2014-12-27 23:47 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-27 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-27
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. As noted in PR 51553 the current behaviour is wrong. Clang and EDG
reject the testcase in this PR.


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

* [Bug c++/64418] User-defined conversion not properly suppressed in certain cases of list-initialisation
  2014-12-27 16:00 [Bug c++/64418] New: User-defined conversion not properly suppressed in certain cases of list-initialisation momchil.velikov at gmail dot com
  2014-12-27 20:11 ` [Bug c++/64418] " redi at gcc dot gnu.org
@ 2014-12-27 23:47 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2014-12-27 23:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
G++ implements the resolution of issue 1467:
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1467

So initialization of a does not use 13.3.1.7.


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

end of thread, other threads:[~2014-12-27 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-27 16:00 [Bug c++/64418] New: User-defined conversion not properly suppressed in certain cases of list-initialisation momchil.velikov at gmail dot com
2014-12-27 20:11 ` [Bug c++/64418] " redi at gcc dot gnu.org
2014-12-27 23:47 ` jason 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).