[cfe-dev] Found a bug - maybe?
Clark Gaebel
cg.wowus.cg at gmail.com
Sun Jun 6 21:09:02 PDT 2010
Here's a reduced test case. Strangely enough, if I change buffer to be
of size 1, this code works fine.
clark at clark-server ~/test $ clang++ --version
clang version 1.1 (branches/release_27)
Target: x86_64-pc-linux-gnu
Thread model: posix
clark at clark-server ~/test $ cat foo.cpp
#include <cstdio> // For printf.
int main()
{
const char buffer[] = {
0x00, 0x11
};
if(buffer > (buffer - 4))
printf("SUCCESS!\n");
else
printf("FAILURE!\n");
}
clark at clark-server ~/test $ clang++ -O0 foo.cpp && ./a.out
SUCCESS!
clark at clark-server ~/test $ clang++ -O2 foo.cpp && ./a.out
FAILURE!
On 06/07/10 00:03, Clark Gaebel wrote:
> A picture is worth a thousand words (and by picture, I mean shell
> output). This is with
>
> clark at clark-server ~/test $ clang++ --version
> clang version 1.1 (branches/release_27)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> clark at clark-server ~/test $ cat foo.cpp
> #include <cstdlib>
> #include <cstdio>
>
> struct ParseFailed {};
>
> int main()
> {
> bool succeeded = false;
>
> const char buffer[] = {
> 0x00, 0x11
> };
>
> try {
> if(buffer > (buffer - 4))
> throw ParseFailed();
>
> succeeded = false;
> } catch(ParseFailed) {
> succeeded = true;
> }
>
> if(succeeded)
> printf("SUCCESS!\n");
> else
> printf("FAILURE!\n");
> }
>
> clark at clark-server ~/test $ clang++ -O0 foo.cpp && ./a.out
> SUCCESS!
> clark at clark-server ~/test $ clang++ -O2 foo.cpp && ./a.out
> FAILURE!
>
> What should I do? This little oddity popped up in one of my unit tests
> while running my codebase through clang.
>
>
--
Regards,
-Clark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100607/33c8dbd0/attachment.html>
More information about the cfe-dev
mailing list