public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25316] New: POD structures can have
@ 2005-12-08 20:48 mrs at apple dot com
2005-12-08 20:51 ` [Bug c++/25316] " mrs at apple dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mrs at apple dot com @ 2005-12-08 20:48 UTC (permalink / raw)
To: gcc-bugs
A user reported that this:
mrs $ cat > t98.c
struct X {
int a, b;
X() : a(0), b(0) {}
};
static void f(const char *s, ...);
int main()
{
X x;
f("foo!", x);
return 0;
}
works on other C++ compilers (Metroworks), but on gcc:
mrs $ ./g++ -B./ -c t98.c
t98.c: In function 'int main()':
t98.c:11: warning: cannot pass objects of non-POD type 'struct X' through
'...'; call will abort at runtime
This, according the a reading of the standard is a POD type, no, really. :-)
Curious though, the same misreading of the text was done by the author of:
3 It is possible to transfer into a block, but not in a way that
bypasses declarations with initialization. A program that jumps77)
from a point where a local variable with automatic storage duration is
not in scope to a point where it is in scope is ill-formed unless the
variable has POD type (_basic.types_) and is declared without an ini-
tializer (_dcl.init_).
as the intent was to not bypass a constructor call.
Also curious is the wording:
To default-initialize an object of type T means:
--if T is a non-POD class type (clause _class_), the default construc-
tor for T is called (and the initialization is ill-formed if T has
no accessible default constructor);
which again reinforces the idea that only non-PODs can have default
constructors called.
Seems like we need a DR to clarify this, if one doesn't aready exist, and then
to fix up the compiler, if any fixups need to be done. I'd expect that the
compiler behavior is correct, but until DRed.
--
Summary: POD structures can have
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mrs at apple dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25316
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/25316] POD structures can have
2005-12-08 20:48 [Bug c++/25316] New: POD structures can have mrs at apple dot com
@ 2005-12-08 20:51 ` mrs at apple dot com
2005-12-08 22:25 ` gdr at integrable-solutions dot net
2005-12-08 23:53 ` mrs at apple dot com
2 siblings, 0 replies; 4+ messages in thread
From: mrs at apple dot com @ 2005-12-08 20:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from mrs at apple dot com 2005-12-08 20:51 -------
Ah, Geoff found it:
The definition of 'aggregate' is in 8.5.1
I new it was there someplace.
--
mrs at apple dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
Summary|POD structures can have |POD structures can have
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25316
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/25316] POD structures can have
2005-12-08 20:48 [Bug c++/25316] New: POD structures can have mrs at apple dot com
2005-12-08 20:51 ` [Bug c++/25316] " mrs at apple dot com
@ 2005-12-08 22:25 ` gdr at integrable-solutions dot net
2005-12-08 23:53 ` mrs at apple dot com
2 siblings, 0 replies; 4+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-12-08 22:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gdr at integrable-solutions dot net 2005-12-08 22:25 -------
Subject: Re: New: POD structures can have
"mrs at apple dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| A user reported that this:
|
| mrs $ cat > t98.c
| struct X {
| int a, b;
| X() : a(0), b(0) {}
| };
|
| static void f(const char *s, ...);
|
| int main()
| {
| X x;
| f("foo!", x);
| return 0;
| }
|
| works on other C++ compilers (Metroworks), but on gcc:
|
| mrs $ ./g++ -B./ -c t98.c
| t98.c: In function 'int main()':
| t98.c:11: warning: cannot pass objects of non-POD type 'struct X' through
| '...'; call will abort at runtime
|
| This, according the a reading of the standard is a POD type, no, really. :-)
Are you saying "struct X" is a POD?
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25316
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/25316] POD structures can have
2005-12-08 20:48 [Bug c++/25316] New: POD structures can have mrs at apple dot com
2005-12-08 20:51 ` [Bug c++/25316] " mrs at apple dot com
2005-12-08 22:25 ` gdr at integrable-solutions dot net
@ 2005-12-08 23:53 ` mrs at apple dot com
2 siblings, 0 replies; 4+ messages in thread
From: mrs at apple dot com @ 2005-12-08 23:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mrs at apple dot com 2005-12-08 23:53 -------
As I said, the prohibition is in 8.5.1 in the definition of aggregate. This is
what makes it not a POD. No DR needed, no gcc bug fix needed, the bug was in
the Metroworks compiler and in the users understanding.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25316
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-12-08 23:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-08 20:48 [Bug c++/25316] New: POD structures can have mrs at apple dot com
2005-12-08 20:51 ` [Bug c++/25316] " mrs at apple dot com
2005-12-08 22:25 ` gdr at integrable-solutions dot net
2005-12-08 23:53 ` mrs at apple dot com
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).