From: Uros Bizjak <ubizjak@gmail.com>
To: GCC <gcc@gcc.gnu.org>
Cc: Dave Korn <dave.korn.cygwin@googlemail.com>,
"H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: What does zero-length array mean at file scope?
Date: Sun, 24 May 2009 09:47:00 -0000 [thread overview]
Message-ID: <4A190D87.6070008@gmail.com> (raw)
Hello!
> I found something rather odd in testcase gcc.c-torture/execute/20030811-1.c:
>
> > /* Origin: PR target/11535 from H. J. Lu <hjl@lucon.org> */
> >
> > void vararg (int i, ...)
> > {
> > (void) i;
> > }
> >
> > int i0[0], i1;
>
> Huh?
>
> > void test1 (void)
> > {
> > int a = (int) (long long) __builtin_return_address (0);
> > vararg (0, a);
> > }
> >
> > void test2 (void)
> > {
> > i0[0] = (int) (long long) __builtin_return_address (0);
> > }
>
> Nasal demons?
>
> > void test3 (void)
> > {
> > i1 = (int) (long long) __builtin_return_address (0);
> > }
> >
> > void test4 (void)
> > {
> > volatile long long a = (long long) __builtin_return_address (0);
> > i0[0] = (int) a;
> > }
>
>
> And testing it on Linux, I see that the linker goes ahead and assigns zero
> bytes of the common area to i0, then assigns four bytes of common space to i1
> at the same address, so writing to i0[0] aliases and alters i1. That
> certainly sounds like undefined behaviour to me!
>
It looks like a typo in the testcase to me, but let's add some CCs to be
sure.
Uros.
next reply other threads:[~2009-05-24 9:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-24 9:47 Uros Bizjak [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-05-24 9:07 Dave Korn
2009-05-24 9:21 ` Dave Korn
2009-05-24 9:26 ` Dave Korn
2009-05-24 10:34 ` Andrew Haley
2009-05-24 10:57 ` Dave Korn
2009-05-24 12:03 ` Andrew Haley
2009-05-24 12:29 ` Dave Korn
2009-05-24 12:41 ` Dave Korn
2009-05-24 20:57 ` Andrew Haley
2009-05-24 22:51 ` Dave Korn
2009-05-28 22:48 ` Joseph S. Myers
2009-05-28 23:18 ` Dave Korn
2009-05-29 10:17 ` Andrew Haley
2009-05-28 22:45 ` Joseph S. Myers
2009-05-29 9:04 ` Dave Korn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A190D87.6070008@gmail.com \
--to=ubizjak@gmail.com \
--cc=dave.korn.cygwin@googlemail.com \
--cc=gcc@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).