From: David Laight <David.Laight@ACULAB.COM>
To: "'llvm@lists.linux.dev'" <llvm@lists.linux.dev>
Subject: clang mis-compiles "x"[2]
Date: Mon, 28 Aug 2023 16:43:10 +0000 [thread overview]
Message-ID: <916414bcf1c349e8a3dc78cb208bf30f@AcuMS.aculab.com> (raw)
Clang mis-compiles:
int foo(void) { return "a"[2]; }
to be just a 'ret' instruction.
While clearly non-sensical returning the input value of %rax
doesn't make any sense.
gcc generates a real string and then returns the byte after
the '\0' - which is (sort of) what the code asks for.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next reply other threads:[~2023-08-28 16:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 16:43 David Laight [this message]
2023-08-28 20:46 ` clang mis-compiles "x"[2] Nick Desaulniers
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=916414bcf1c349e8a3dc78cb208bf30f@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=llvm@lists.linux.dev \
/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