C++ PATCH for DR 1518 (c++/54835, c++/60417)

Jason Merrill jason@redhat.com
Wed Oct 28 19:09:00 GMT 2015


On 10/26/2015 10:47 AM, Jason Merrill wrote:
> On 10/25/2015 09:04 PM, Ville Voutilainen wrote:
>> On 25 October 2015 at 22:15, Ville Voutilainen
>> <ville.voutilainen@gmail.com> wrote:
>>> It seems to me that there's a discrepancy in handling explicit
>>> default constructors. Based on my tests, this works:
>>>
>>> struct X {explicit X() {}};
>>>
>>> void f(X) {}
>>>
>>> int main()
>>> {
>>>      f({});
>>> }
>>>
>>> However, if the explicit constructor is defaulted, gcc accepts the code:
>>>
>>> struct X {explicit X() = default;};
>>>
>>> void f(X) {}
>>>
>>> int main()
>>> {
>>>      f({});
>>> }
>>
>> And to clarify, I'd expect both of those snippets to be rejected, but
>> only the
>> former is.
>
> The latter is accepted because the second X is an aggregate, and the
> aggregate initialization bullet comes before value-initialization in 8.5.4.

Further discussion on -core leads me to try changing X to be 
non-aggregate because of the explicit constructor.

Tested x86_64-pc-linux-gnu, applying to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: dr1518-2.patch
Type: text/x-patch
Size: 3154 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151028/85b02050/attachment.bin>


More information about the Gcc-patches mailing list