public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48777] New: duplicate pointers to empty structs passed as arguments to function
@ 2011-04-26 19:14 mjh at edg dot com
2011-04-26 19:22 ` [Bug c/48777] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mjh at edg dot com @ 2011-04-26 19:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48777
Summary: duplicate pointers to empty structs passed as
arguments to function
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mjh@edg.com
#if OKAY
typedef int TYPE;
#elif ALSO_OKAY
struct A { int i; };
typedef struct A TYPE;
#else
struct A {};
typedef struct A TYPE;
#endif
int f(TYPE *a1, TYPE *a2) {
return a1 == a2;
}
int main(void) {
TYPE a1, a2;
return f(&a1, &a2);
}
When OKAY or ALSO_OKAY are defined, unique addresses are passed for the
arguments to "f", but when an empty struct is used, the same address is passed
for both arguments (causing the function "f" to return 1).
This regression appears to have been introduced in 4.0.0 and exists through
4.5.2 (the latest version I have).
Thanks,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/48777] duplicate pointers to empty structs passed as arguments to function
2011-04-26 19:14 [Bug c/48777] New: duplicate pointers to empty structs passed as arguments to function mjh at edg dot com
@ 2011-04-26 19:22 ` pinskia at gcc dot gnu.org
2011-04-26 19:49 ` joseph at codesourcery dot com
2014-03-26 8:31 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-04-26 19:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48777
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-04-26 19:20:31 UTC ---
Considering empty structs are a GNU extension, this could be considered
correct.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/48777] duplicate pointers to empty structs passed as arguments to function
2011-04-26 19:14 [Bug c/48777] New: duplicate pointers to empty structs passed as arguments to function mjh at edg dot com
2011-04-26 19:22 ` [Bug c/48777] " pinskia at gcc dot gnu.org
@ 2011-04-26 19:49 ` joseph at codesourcery dot com
2014-03-26 8:31 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2011-04-26 19:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48777
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-04-26 19:48:53 UTC ---
Indeed, empty structs in GNU C (as opposed to C++) are expected to take up
no space, and so possibly not have unique addresses.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/48777] duplicate pointers to empty structs passed as arguments to function
2011-04-26 19:14 [Bug c/48777] New: duplicate pointers to empty structs passed as arguments to function mjh at edg dot com
2011-04-26 19:22 ` [Bug c/48777] " pinskia at gcc dot gnu.org
2011-04-26 19:49 ` joseph at codesourcery dot com
@ 2014-03-26 8:31 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-03-26 8:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48777
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |mpolacek at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thus closing.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-26 8:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 19:14 [Bug c/48777] New: duplicate pointers to empty structs passed as arguments to function mjh at edg dot com
2011-04-26 19:22 ` [Bug c/48777] " pinskia at gcc dot gnu.org
2011-04-26 19:49 ` joseph at codesourcery dot com
2014-03-26 8:31 ` mpolacek at gcc dot gnu.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).