public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21917] Missing warning?
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
@ 2005-11-24 2:25 ` gdr at gcc dot gnu dot org
2007-01-09 15:02 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-11-24 2:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from gdr at gcc dot gnu dot org 2005-11-24 02:25 -------
(In reply to comment #2)
> This is how C++ is done, maybe a warning can be emitted but it seems like it
> will emitt too much for
> valid C++ code.
>
I don't know; the code shown is very contrived to my taste.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-11-24 02:25:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21917] Missing warning?
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
2005-11-24 2:25 ` [Bug c++/21917] Missing warning? gdr at gcc dot gnu dot org
@ 2007-01-09 15:02 ` manu at gcc dot gnu dot org
2007-01-09 16:36 ` igodard at pacbell dot net
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-09 15:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from manu at gcc dot gnu dot org 2007-01-09 15:02 -------
Have you tried compiling with -pedantic -Wall -Wextra ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21917] Missing warning?
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
2005-11-24 2:25 ` [Bug c++/21917] Missing warning? gdr at gcc dot gnu dot org
2007-01-09 15:02 ` manu at gcc dot gnu dot org
@ 2007-01-09 16:36 ` igodard at pacbell dot net
2007-01-20 16:52 ` [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base manu at gcc dot gnu dot org
2008-06-05 23:07 ` r_q_einstein-gccgnuorg at yahoo dot com
4 siblings, 0 replies; 8+ messages in thread
From: igodard at pacbell dot net @ 2007-01-09 16:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from igodard at pacbell dot net 2007-01-09 16:36 -------
No message on 4.1.1 despite -pedantic -Wall -Wextra
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-01-09 16:36 ` igodard at pacbell dot net
@ 2007-01-20 16:52 ` manu at gcc dot gnu dot org
2008-06-05 23:07 ` r_q_einstein-gccgnuorg at yahoo dot com
4 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-20 16:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2007-01-20 16:52 -------
Not sure if the summary is 100% correct but it is far better than the previous
one.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Missing warning? |Missing warning when trying
| |to explicitly construct a
| |virtual base
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-01-20 16:52 ` [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base manu at gcc dot gnu dot org
@ 2008-06-05 23:07 ` r_q_einstein-gccgnuorg at yahoo dot com
4 siblings, 0 replies; 8+ messages in thread
From: r_q_einstein-gccgnuorg at yahoo dot com @ 2008-06-05 23:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from r_q_einstein-gccgnuorg at yahoo dot com 2008-06-05 23:07 -------
I've run across this, too.
I agree with Ivan's 2005-06-04 suggestion.
It would be nice if the compiler would emit a warning that the derived class's
constructor's call to the virtual base class's non-default constructor is being
ignored and overridden by an implicit call to the virtual base class's default
constructor.
Similarly, if the virtual base class fails to specify a default constructor
(and specifies only a non-default one), the derived class's constructor's call
to the virtual base class's non-default constructor produces only this error
message:
In constructor 'top::top()':
error: no matching function for call to 'virt::virt()'
which leaves the developer scratching his/her head if he doesn't know that the
C++ spec. requires virtual base classes to have default constructors. (True,
s/he should know, but the compile error message could be more helpful.)
Something to the effect of:
"virtual base class lacks default constructor" would be much more helpful.
If this issue is different enough to warrant a separate "bug" report, let me
know and I'll be happy to file it separately.
Thanks.
--
r_q_einstein-gccgnuorg at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |r_q_einstein-gccgnuorg at
| |yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21917] New: Missing warning? (or error?)
@ 2005-06-04 22:18 igodard at pacbell dot net
2005-06-06 1:24 ` [Bug c++/21917] Missing warning? pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: igodard at pacbell dot net @ 2005-06-04 22:18 UTC (permalink / raw)
To: gcc-bugs
struct virt { virt() : i(2) {} virt(int i) : i(i){} int i; };
struct der1 : public virtual virt { der1(int i) : virt(i) {} };
struct der2 : public virtual virt { der2(int i) : virt(i) {} };
struct top : public der1, public der2 {
top () : der1(0), der2(1) {} };
int main() { top t; }
Compiles without comment. However, the null constructor for "virt" is called
rather than the explicit constructor that is indicated by the constructor chain
from top. In fact, the der* constructors say " : virt(i)" but that
sub-constructor will never be called because virt is a virtual base class.
I don't know if it is actually an error to try to explicitly construct a virtual
base, but is sure is misleading and I think deserves at least a warning.
--
Summary: Missing warning? (or error?)
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-06-05 23:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
2005-11-24 2:25 ` [Bug c++/21917] Missing warning? gdr at gcc dot gnu dot org
2007-01-09 15:02 ` manu at gcc dot gnu dot org
2007-01-09 16:36 ` igodard at pacbell dot net
2007-01-20 16:52 ` [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base manu at gcc dot gnu dot org
2008-06-05 23:07 ` r_q_einstein-gccgnuorg at yahoo dot com
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
2005-06-06 1:24 ` [Bug c++/21917] Missing warning? pinskia at gcc dot gnu dot org
2005-07-13 13:17 ` pinskia at gcc dot gnu dot org
2005-07-13 13:31 ` pinskia 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).