<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Here's a reduced test case. Strangely enough, if I change buffer to be
of size 1, this code works fine.<br>
<br>
<blockquote>clark@clark-server ~/test $ clang++ --version<br>
clang version 1.1 (branches/release_27)<br>
Target: x86_64-pc-linux-gnu<br>
Thread model: posix<br>
clark@clark-server ~/test $ cat foo.cpp<br>
#include <cstdio> // For printf.<br>
<br>
int main()<br>
{<br>
const char buffer[] = {<br>
0x00, 0x11<br>
};<br>
<br>
if(buffer > (buffer - 4))<br>
printf("SUCCESS!\n");<br>
else<br>
printf("FAILURE!\n");<br>
}<br>
<br>
clark@clark-server ~/test $ clang++ -O0 foo.cpp && ./a.out<br>
SUCCESS!<br>
clark@clark-server ~/test $ clang++ -O2 foo.cpp && ./a.out<br>
FAILURE!<br>
</blockquote>
<br>
<br>
On 06/07/10 00:03, Clark Gaebel wrote:
<blockquote cite="mid:4C0C6F8A.4020707@gmail.com" type="cite">
<pre wrap="">A picture is worth a thousand words (and by picture, I mean shell
output). This is with
clark@clark-server ~/test $ clang++ --version
clang version 1.1 (branches/release_27)
Target: x86_64-pc-linux-gnu
Thread model: posix
clark@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@clark-server ~/test $ clang++ -O0 foo.cpp && ./a.out
SUCCESS!
clark@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.
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Regards,
-Clark</pre>
</body>
</html>