public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21917] New: Missing warning? (or error?)
@ 2005-06-04 22:18 igodard at pacbell dot net
2005-06-04 22:22 ` [Bug c++/21917] " igodard at pacbell dot net
` (4 more replies)
0 siblings, 5 replies; 6+ 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] 6+ messages in thread
* [Bug c++/21917] Missing warning? (or error?)
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
@ 2005-06-04 22:22 ` igodard at pacbell dot net
2005-06-05 3:03 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: igodard at pacbell dot net @ 2005-06-04 22:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From igodard at pacbell dot net 2005-06-04 22:22 -------
p.s. I suppose that if there is only a single path to the virtual base then
explicit construction is meaningful and the explicit construction in the der*
classes is not wrong. But in the constructor for "top" the compiler knows that
there are multiple derivations from virt (it has to or it couldn't know to call
the null constructor), so the warning could be issued in "top". Something like
"base constructor virt(int) in der1(int) bypassed, virt() used instead"?
Ivan
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/21917] Missing warning? (or error?)
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
2005-06-04 22:22 ` [Bug c++/21917] " igodard at pacbell dot net
@ 2005-06-05 3:03 ` pinskia at gcc dot gnu dot org
2005-06-06 1:24 ` [Bug c++/21917] Missing warning? pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-05 3:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-05 03:02 -------
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.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/21917] Missing warning?
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
2005-06-04 22:22 ` [Bug c++/21917] " igodard at pacbell dot net
2005-06-05 3:03 ` pinskia at gcc dot gnu dot org
@ 2005-06-06 1:24 ` 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
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-06 1:24 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|Missing warning? (or error?)|Missing warning?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/21917] Missing warning?
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-13 13:17 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/21917] Missing warning?
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
` (3 preceding siblings ...)
2005-07-13 13:17 ` pinskia at gcc dot gnu dot org
@ 2005-07-13 13:31 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-13 13:31 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-07-13 13:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-04 22:18 [Bug c++/21917] New: Missing warning? (or error?) igodard at pacbell dot net
2005-06-04 22:22 ` [Bug c++/21917] " igodard at pacbell dot net
2005-06-05 3:03 ` pinskia at gcc dot gnu dot org
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).