* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-03 22:28 ` dirtyepic at gentoo dot org
2011-03-03 23:14 ` redi at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-03-03 22:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
Ryan Hill <dirtyepic at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dirtyepic at gentoo dot org
--- Comment #10 from Ryan Hill <dirtyepic at gentoo dot org> 2011-03-03 22:28:45 UTC ---
(In reply to comment #3)
> (In reply to comment #1)
> > gcc is correct, accepting the code previously was a bug that was fixed recently
> >
> > You need to provide an initializer for g_d
>
> This sort of changes should be documented in the changes.html page or in
> porting_to.html
Could this be added? Some upstreams are arguing this is a bug in GCC. In the
past we've found that if it's documented that this change was indeed
intentional, they're more willing to fix their code.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
2011-03-03 22:28 ` [Bug c++/44499] No default constructor available dirtyepic at gentoo dot org
@ 2011-03-03 23:14 ` redi at gcc dot gnu.org
2011-03-03 23:16 ` redi at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-03 23:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-03 23:14:10 UTC ---
(In reply to comment #10)
> (In reply to comment #3)
> > (In reply to comment #1)
> > > gcc is correct, accepting the code previously was a bug that was fixed recently
> > >
> > > You need to provide an initializer for g_d
> >
> > This sort of changes should be documented in the changes.html page or in
> > porting_to.html
I prepared this:
<li>As required by the C++ standard, G++ no longer allows objects of
const-qualified type to be default initialized unless the type has a
user-declared default constructor. Code that fails to compile can be
fixed by providing an initializer e.g.
<pre>
struct S { };
const S s = S();
</pre>
Use <code>-fpermissive</code> to allow the old, non-conforming behaviour.
</li>
However ...
> Could this be added? Some upstreams are arguing this is a bug in GCC. In the
> past we've found that if it's documented that this change was indeed
> intentional, they're more willing to fix their code.
GCC 4.4 and 4.5 reject the example too, so I don't know when the bug was fixed,
it's apparently not a change in 4.6 (though there were some bugs in this area
fixed recently.)
Upstream will have to accept that G++ (like Clang++ and EDG) conforms to the
standard in this respect.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
2011-03-03 22:28 ` [Bug c++/44499] No default constructor available dirtyepic at gentoo dot org
2011-03-03 23:14 ` redi at gcc dot gnu.org
@ 2011-03-03 23:16 ` redi at gcc dot gnu.org
2011-03-04 10:02 ` manu at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-03 23:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-03 23:16:41 UTC ---
Manu, can we close this?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-03-03 23:16 ` redi at gcc dot gnu.org
@ 2011-03-04 10:02 ` manu at gcc dot gnu.org
2011-03-04 11:23 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-03-04 10:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #13 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-03-04 10:02:19 UTC ---
(In reply to comment #12)
> Manu, can we close this?
@Jonathan
I still think that the messages of Comeau and Clang are better than GCC's. I
will try for 4.7 to produce a patch to change the message to be like:
error: default initialization of const object 'g_d' requires a user-provided
default constructor [-fpermissive]
note: 'const class D' has no user-provided default constructor
Do you agree?
(I'd like to keep the note to jump to the declaration of class D).
@Piotr,Ryan
I started a list of GCC diagnostics in the wiki.
http://gcc.gnu.org/wiki/VerboseDiagnostics
There is only one but the idea would be to collect in a single place extended
explanations and fix-it hints about gcc diagnostics. Perhaps in the future such
knowledge can be added to the compiler proper and enabled with a
-fdiagnostics-explain or -fdiagnostics-fix-it.
I think this could be a killer-feature for GCC to have, but collecting the data
is a lot of work for a single person. This is a way to contribute to GCC
without writing a single line of code!
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-03-04 10:02 ` manu at gcc dot gnu.org
@ 2011-03-04 11:23 ` redi at gcc dot gnu.org
2011-03-04 11:25 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-04 11:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-04 11:23:41 UTC ---
(In reply to comment #13)
> (In reply to comment #12)
> > Manu, can we close this?
>
> @Jonathan
>
> I still think that the messages of Comeau and Clang are better than GCC's. I
> will try for 4.7 to produce a patch to change the message to be like:
>
> error: default initialization of const object 'g_d' requires a user-provided
> default constructor [-fpermissive]
> note: 'const class D' has no user-provided default constructor
>
> Do you agree?
Sure, if you still plan to improve it let's definitely keep it open.
> (I'd like to keep the note to jump to the declaration of class D).
Ah yes, that's useful.
In the spirit of providing "fix it" hints, I think the EDG diagnostic is
better. There are two ways to avoid the error:
1) Add a default constructor. This changes the type in non-trivial ways with
potentially large side-effects in terms of POD-ness, affecting all users of the
code and requiring recompilation. It's not even possible for classes defined in
third-party headers.
2) Use an initializer. This doesn't change the type and is a purely local
change.
The second option is probably the right one in most cases :)
"Expert" users who know what they're doing can choose to alter the class, but I
don't think we should suggest they do so.
How about this:
error: Const object 'g_d' requires an initializer [-fpermissive]
note: 'const class D' has no user-provided default constructor
The error refers to the variable's location and says an initializer is needed.
The note refers to the class' location and says it has no default constructor.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2011-03-04 11:23 ` redi at gcc dot gnu.org
@ 2011-03-04 11:25 ` redi at gcc dot gnu.org
2011-03-17 11:46 ` dirtyepic at gentoo dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-04 11:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Severity|normal |enhancement
--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-04 11:25:01 UTC ---
changing Severity and Keywords to clarify the outstanding work is just a
diagnostic enhancement
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2011-03-04 11:25 ` redi at gcc dot gnu.org
@ 2011-03-17 11:46 ` dirtyepic at gentoo dot org
2011-03-17 11:46 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-03-17 11:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #16 from Ryan Hill <dirtyepic at gentoo dot org> 2011-03-17 11:36:15 UTC ---
(In reply to comment #11)
> GCC 4.4 and 4.5 reject the example too, so I don't know when the bug was fixed,
> it's apparently not a change in 4.6 (though there were some bugs in this area
> fixed recently.)
Hmm, that particular example does fail. But we've still been seeing this in
packages such as xulrunner and openjade that are fine with 4.5, so some
variation of the example is a new error. eg. this only fails with 4.6:
struct A { int a; A (); };
struct B : public A { };
const B b;
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2011-03-17 11:46 ` dirtyepic at gentoo dot org
@ 2011-03-17 11:46 ` redi at gcc dot gnu.org
2011-03-19 20:05 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-17 11:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-17 11:45:35 UTC ---
(In reply to comment #16)
> (In reply to comment #11)
> > GCC 4.4 and 4.5 reject the example too, so I don't know when the bug was fixed,
> > it's apparently not a change in 4.6 (though there were some bugs in this area
> > fixed recently.)
>
> Hmm, that particular example does fail. But we've still been seeing this in
> packages such as xulrunner and openjade that are fine with 4.5, so some
> variation of the example is a new error. eg. this only fails with 4.6:
>
> struct A { int a; A (); };
> struct B : public A { };
> const B b;
Yup, that fails with 4.6, as it should. It's also rejected by EDG and Clang,
but not VC++
OK, I'll update the changes page with a variation of the note in comment 11,
but upstream should still read the standard and deal with it ;)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2011-03-17 11:46 ` redi at gcc dot gnu.org
@ 2011-03-19 20:05 ` redi at gcc dot gnu.org
2011-09-25 11:46 ` [Bug c++/44499] [4.7 Regression?] " paolo.carlini at oracle dot com
` (3 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-19 20:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-19 19:56:49 UTC ---
(In reply to comment #17)
> OK, I'll update the changes page with a variation of the note in comment 11,
done
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] [4.7 Regression?] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2011-03-19 20:05 ` redi at gcc dot gnu.org
@ 2011-09-25 11:46 ` paolo.carlini at oracle dot com
2011-09-25 14:23 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-25 11:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org,
| |paolo.carlini at oracle dot
| |com
Summary|No default constructor |[4.7 Regression?] No
|available |default constructor
| |available
--- Comment #19 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-25 11:41:02 UTC ---
In mainline this is accepted again! Is it a regression?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] [4.7 Regression?] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2011-09-25 11:46 ` [Bug c++/44499] [4.7 Regression?] " paolo.carlini at oracle dot com
@ 2011-09-25 14:23 ` redi at gcc dot gnu.org
2011-09-25 14:39 ` [Bug c++/44499] " paolo.carlini at oracle dot com
2014-02-16 10:02 ` jackie.rosen at hushmail dot com
12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-09-25 14:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #20 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-25 13:57:13 UTC ---
Probably this change:
2011-09-23 Jason Merrill <jason@redhat.com>
Core 253 - allow const objects with no initializer or
user-provided default constructor if the defaulted constructor
initializes all the subobjects.
PR c++/20039
PR c++/42844
* class.c (default_init_uninitialized_part): New.
* cp-tree.h: Declare it.
* decl.c (check_for_uninitialized_const_var): Use it.
* init.c (perform_member_init): Likewise.
(build_new_1): Likewise.
* method.c (walk_field_subobs): Likewise.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (10 preceding siblings ...)
2011-09-25 14:23 ` redi at gcc dot gnu.org
@ 2011-09-25 14:39 ` paolo.carlini at oracle dot com
2014-02-16 10:02 ` jackie.rosen at hushmail dot com
12 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-25 14:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |WORKSFORME
Target Milestone|--- |4.7.0
Summary|[4.7 Regression?] No |No default constructor
|default constructor |available
|available |
--- Comment #21 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-25 14:11:52 UTC ---
Oh, indeed. Then I guess this can be simply closed for 4.7.0, the diagnostic
issue is now moot.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/44499] No default constructor available
[not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
` (11 preceding siblings ...)
2011-09-25 14:39 ` [Bug c++/44499] " paolo.carlini at oracle dot com
@ 2014-02-16 10:02 ` jackie.rosen at hushmail dot com
12 siblings, 0 replies; 13+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 10:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
Jackie Rosen <jackie.rosen at hushmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jackie.rosen at hushmail dot com
--- Comment #22 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Marked for reference. Resolved as fixed @bugzilla.
^ permalink raw reply [flat|nested] 13+ messages in thread