public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44499] New: No default constructor available
@ 2010-06-11 9:10 piotr dot wyderski at gmail dot com
2010-06-11 9:26 ` [Bug c++/44499] " redi at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: piotr dot wyderski at gmail dot com @ 2010-06-11 9:10 UTC (permalink / raw)
To: gcc-bugs
The following code:
class C {
};
class D : public C {
};
const D g_d;
fails to compile on trunk (rev. 160489) with the following message:
$ g++ test.cpp
test.cpp:11:9: error: uninitialized const 'g_d' [-fpermissive]
test.cpp:6:11: note: 'const class D' has no user-provided default constructor
--
Summary: No default constructor available
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: piotr dot wyderski at gmail dot com
GCC build triplet: i686-pc-cygwin
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
@ 2010-06-11 9:26 ` redi at gcc dot gnu dot org
2010-06-11 10:28 ` redi at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-06-11 9:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from redi at gcc dot gnu dot org 2010-06-11 09:26 -------
gcc is correct, accepting the code previously was a bug that was fixed recently
You need to provide an initializer for g_d
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
2010-06-11 9:26 ` [Bug c++/44499] " redi at gcc dot gnu dot org
@ 2010-06-11 10:28 ` redi at gcc dot gnu dot org
2010-06-11 10:53 ` manu at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-06-11 10:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from redi at gcc dot gnu dot org 2010-06-11 10:27 -------
A question: apart from quoting chapter and verse from the standard (8.5
[dcl.init], para 9 in C++03, para 6 in C++0x,) how could the diagnostic have
been any clearer?
It indicates you can use -fpermissive to relax the warning, and it includes a
note telling you the type has no user-provided default constructor, which is
true. Why would you assume this is a bug, when a developer has gone to the
trouble of writing the note?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
2010-06-11 9:26 ` [Bug c++/44499] " redi at gcc dot gnu dot org
2010-06-11 10:28 ` redi at gcc dot gnu dot org
@ 2010-06-11 10:53 ` manu at gcc dot gnu dot org
2010-06-11 11:01 ` piotr dot wyderski at gmail dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-06-11 10:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2010-06-11 10:53 -------
(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
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (2 preceding siblings ...)
2010-06-11 10:53 ` manu at gcc dot gnu dot org
@ 2010-06-11 11:01 ` piotr dot wyderski at gmail dot com
2010-06-11 11:12 ` manu at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: piotr dot wyderski at gmail dot com @ 2010-06-11 11:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from piotr dot wyderski at gmail dot com 2010-06-11 11:01 -------
(In reply to comment #2)
> A question: apart from quoting chapter and verse from the standard (8.5
> [dcl.init], para 9 in C++03, para 6 in C++0x,) how could the diagnostic have
> been any clearer?
>
> It indicates you can use -fpermissive to relax the warning, and it includes a
> note telling you the type has no user-provided default constructor, which is
> true. Why would you assume this is a bug, when a developer has gone to the
> trouble of writing the note?
All the compilers I am aware of accept the aforementioned construction,
so I blindly assumed that 4.6 is wrong in issuing a warning. The note's
content was considered irrelevant, since no error was expected. But if
the behaviour is OK, then it is OK no matter what a surprise it turns out to
be.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (4 preceding siblings ...)
2010-06-11 11:12 ` manu at gcc dot gnu dot org
@ 2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:14 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-06-11 11:12 UTC (permalink / raw)
To: gcc-bugs
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |manu at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-06-11 11:11:57
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (3 preceding siblings ...)
2010-06-11 11:01 ` piotr dot wyderski at gmail dot com
@ 2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:12 ` manu at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-06-11 11:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2010-06-11 11:11 -------
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 9: error: const variable "g_d" requires an initializer --
class
"D" has no explicitly declared default constructor
const D g_d;
^
"ComeauTest.c", line 9: warning: variable "g_d" was declared but never
referenced
const D g_d;
^
1 error detected in the compilation of "ComeauTest.c".
I think the error message of comeau is better (but our note is better). I will
write a patch.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (5 preceding siblings ...)
2010-06-11 11:12 ` manu at gcc dot gnu dot org
@ 2010-06-11 11:14 ` manu at gcc dot gnu dot org
2010-07-02 8:09 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-06-11 11:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2010-06-11 11:13 -------
LLVM is still using GCC in their demo, not Clang. So I cannot test their
output.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (6 preceding siblings ...)
2010-06-11 11:14 ` manu at gcc dot gnu dot org
@ 2010-07-02 8:09 ` manu at gcc dot gnu dot org
2010-07-02 8:12 ` pluto at agmk dot net
2010-07-02 9:15 ` manu at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-07-02 8:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from manu at gcc dot gnu dot org 2010-07-02 08:09 -------
Could someone test what clang says here? Their diagnostics are generally better
than g++.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (7 preceding siblings ...)
2010-07-02 8:09 ` manu at gcc dot gnu dot org
@ 2010-07-02 8:12 ` pluto at agmk dot net
2010-07-02 9:15 ` manu at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pluto at agmk dot net @ 2010-07-02 8:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pluto at agmk dot net 2010-07-02 08:12 -------
(In reply to comment #7)
> Could someone test what clang says here? Their diagnostics are generally better
> than g++.
>
$ clang++ pr44499.cpp -c
pr44499.cpp:5:9: error: default initialization of an object of const type 'D
const' requires a user-provided default constructor
const D g_d;
^
1 error generated.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/44499] No default constructor available
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
` (8 preceding siblings ...)
2010-07-02 8:12 ` pluto at agmk dot net
@ 2010-07-02 9:15 ` manu at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-07-02 9:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from manu at gcc dot gnu dot org 2010-07-02 09:15 -------
Thanks Pawel,
which diagnostic do you prefer?
I would favor clang's but I would still keep the note that points to the class
definition.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-07-02 9:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-11 9:10 [Bug c++/44499] New: No default constructor available piotr dot wyderski at gmail dot com
2010-06-11 9:26 ` [Bug c++/44499] " redi at gcc dot gnu dot org
2010-06-11 10:28 ` redi at gcc dot gnu dot org
2010-06-11 10:53 ` manu at gcc dot gnu dot org
2010-06-11 11:01 ` piotr dot wyderski at gmail dot com
2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:14 ` manu at gcc dot gnu dot org
2010-07-02 8:09 ` manu at gcc dot gnu dot org
2010-07-02 8:12 ` pluto at agmk dot net
2010-07-02 9:15 ` manu at gcc dot gnu dot 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).