[LLVMbugs] [Bug 4814] New: possible integer wrong code bug
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Aug 28 08:35:22 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=4814
Summary: possible integer wrong code bug
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: regehr at cs.utah.edu
CC: llvmbugs at cs.uiuc.edu
Seen on Ubuntu Hardy.
g_96 is initialized to 1 and perhaps at -O3 we're forgetting to zero it in the
loop?
regehr at john-home:~/volatile/tmp190$ llvm-gcc -O2 small.c -o small -w
regehr at john-home:~/volatile/tmp190$ ./small
checksum = 0
regehr at john-home:~/volatile/tmp190$ llvm-gcc -O3 small.c -o small -w
regehr at john-home:~/volatile/tmp190$ ./small
checksum = 1
regehr at john-home:~/volatile/tmp190$ llvm-gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure
--prefix=/home/regehr/z/tmp/llvm-gcc-r80328-install
--program-prefix=llvm-r80328- --enable-languages=c,c++
--enable-llvm=/home/regehr/z/tmp/llvm-r80328 --enable-checking=release
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5649) (LLVM build)
regehr at john-home:~/volatile/tmp190$ cat small.c
#include <stdint.h>
#include <limits.h>
#include <stdio.h>
#define safe_rshift_macro_int8_t_s_u(left,right) \
(((((int8_t)(left)) < ((int8_t)0)) \
|| (((unsigned int)(right)) >=
sizeof(int8_t)*CHAR_BIT)) \
? ((int8_t)(left)) \
: (((int8_t)(left)) >> ((unsigned int)(right))))
static int8_t
safe_rshift_func_int8_t_s_u(int8_t _left, unsigned int _right)
{
return safe_rshift_macro_int8_t_s_u(_left,_right);
}
struct S0
{
uint8_t f0;
uint8_t f1;
uint8_t f2;
};
uint8_t g_3 = 0xB4E1265AL;
uint8_t g_96 = 1;
volatile uint8_t g_100;
struct S0 func_47 (void);
struct S0 func_47 (void)
{
struct S0 l_74 = {
0xB9CEB518L, 0x4A9CL, 1
};
return l_74;
}
int32_t func_18 (struct S0 p_19);
int32_t func_18 (struct S0 p_19)
{
if (g_96 >= (1 || p_19.f1))
g_100;
return 1;
}
int32_t func_4 (int64_t p_5, uint32_t p_6);
int32_t func_4 (int64_t p_5, uint32_t p_6)
{
struct S0 l_116 = {
0xA76FC585L, 7L, 1
};
func_18 (l_116);
return l_116.f2;
}
void func_1 (void);
void func_1 (void)
{
uint8_t l_2;
uint8_t l_120 = 0;
for (l_2 = 0; l_2 <= 0; l_2++)
if (safe_rshift_func_int8_t_s_u (g_3, func_4 (0, 1)))
for (g_96 = 0; 0; 1)
{
}
else if (func_18 (func_47 ()))
for (1; l_120; l_120 = 1)
{
}
}
int main (void)
{
func_1 ();
printf ("checksum = %d\n", g_96);
return 0;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list