Bug 60284

Summary: [DR 253] Default-initialization without user-provided constructor allowed
Product: gcc Reporter: David Krauss <potswa>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: dushistov, webrown.cpp
Priority: P3 Keywords: accepts-invalid
Version: 4.9.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66109
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89305
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57820
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2014-02-20 00:00:00
Bug Depends on:    
Bug Blocks: 94404    

Description David Krauss 2014-02-20 08:52:29 UTC
This declaration is ill-formed according to the last sentence of [dcl.init] ยง8.5/7, "If a program calls for the default initialization of an object of a const-qualified type T, T shall be a class type with a user-provided default constructor":

struct a {} const o;

There is actually a very nice diagnostic implemented by r179170 and PR42844, but it's only activated when the class has an uninitialized member, per the notes of CWG DR 253. However those notes aren't normative and Clang diagnoses the error, http://stackoverflow.com/q/21900237/153285 .
Comment 1 Jonathan Wakely 2014-02-20 09:20:35 UTC
This is by design, because as DR 253 shows, the normative standard is flawed.
Comment 2 Andrew Pinski 2024-04-04 00:20:21 UTC
From cwg253 (https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253):
[Adopted at the November, 2016 meeting as part of paper P0490R0.]


But I can't tell if it was a adopted as a defect report or just implemented as part of C++17.