Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #546

Re: Defect Report: Direct class initialization via explicit conversion function to arbitrary class type

From Daniel Krügler <daniel.kruegler@googlemail.com>
Newsgroups comp.std.c++
Subject Re: Defect Report: Direct class initialization via explicit conversion function to arbitrary class type
Date 2012-09-18 13:06 -0700
Organization A noiseless patient Spider
Message-ID <k3aicr$kt7$1@dont-email.me> (permalink)
References <bc0565dc-1fc6-47be-a997-67b0e5ed5127@googlegroups.com>

Show all headers | View raw


Am 18.09.2012 17:24, schrieb Edward Catmur:
>
> The resolution of issue 1087[1] was intended to permit the use of an explicit
> conversion function in direct-initialization of a class type object via a copy-,
> move- or template constructor.  Unfortunately, the language used is sufficiently
> lax to permit the use of a converting constructor taking class type:
>
>       struct X {};
>       struct Y { Y(const X&); };    // converting constructor
>       struct Z { explicit operator X() const; };
>       void h(Z z) {
>         Y y1(z);    // should not be permitted
>       }
>
> The converting constructor of Y is considered for direct-initialization
> (13.3.1.3 [over.match.ctor]), and to initialize the temporary X to be bound to
> the first parameter of the constructor (13.3.1.4 [over.match.copy]), the
> explicit conversion function of Z is considered.  13.3.1.4 should be tightened
> to not apply to converting constructors.
>
> When discussing this issue[2], it became apparent that the definition of
> conversion functions in 12.3.2 [class.conv.fct] does not make it clear that the
> validity of explicit conversion functions in a direct-initialization expression
> is governed by the semantics of overload resolution. A cross-reference to the
> relevant sections would help here.


I forwarded this to the core language working group.

Thanks & Greetings from Bremen,

Daniel Kr�gler



--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Find similar


Thread

Defect Report: Direct class initialization via explicit conversion   function to arbitrary class type Edward Catmur<ed@catmur.co.uk> - 2012-09-18 08:24 -0700
  Re: Defect Report: Direct class initialization via explicit conversion   function to arbitrary class type Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-09-18 13:06 -0700

csiph-web