[LLVMbugs] [Bug 4053] New: integer wrong code bug
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Apr 24 08:54:45 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=4053
Summary: integer wrong code bug
Product: new-bugs
Version: unspecified
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 using r69856 on Ubuntu Hardy on x86.
1 is the right answer.
regehr at john-home:~/volatile/tmp154$ llvm-gcc -O0 small.c -o small -w
regehr at john-home:~/volatile/tmp154$ ./small
checksum = 1
regehr at john-home:~/volatile/tmp154$ llvm-gcc -O1 small.c -o small -w
regehr at john-home:~/volatile/tmp154$ ./small
checksum = 0
#include <stdint.h>
#define safe_add_macro_int64_t_s_s(si1,si2) \
((((((int64_t)(si1))>((int64_t)0)) &&
(((int64_t)(si2))>((int64_t)0)) && (((int64_t)(si1)) >
((INT64_MAX)-((int64_t)(si2))))) \
|| ((((int64_t)(si1))<((int64_t)0)) &&
(((int64_t)(si2))<((int64_t)0)) && (((int64_t)(si1)) <
((INT64_MIN)-((int64_t)(si2)))))) \
? ((int64_t)(si1)) \
: (((int64_t)(si1)) + ((int64_t)(si2))) \
)
static int64_t
safe_add_func_int64_t_s_s(int64_t _si1, int64_t _si2)
{
return safe_add_macro_int64_t_s_s(_si1,_si2);
}
#define safe_mod_macro_uint16_t_u_u(ui1,ui2) \
((((uint16_t)(ui2)) == ((uint16_t)0)) \
? ((uint16_t)(ui1)) \
: (((uint16_t)(ui1)) % ((uint16_t)(ui2))))
static uint16_t
safe_mod_func_uint16_t_u_u (uint16_t _ui1, uint16_t _ui2)
{
return safe_mod_macro_uint16_t_u_u(_ui1,_ui2);
}
uint8_t g_8;
void func_2 (int16_t p_4);
void func_2 (int16_t p_4)
{
for (p_4 = 0; (p_4 >= 0); p_4 = safe_add_func_int64_t_s_s (p_4, 1))
{
g_8 = safe_mod_func_uint16_t_u_u (1, 0);
}
}
int main (void)
{
func_2 (1);
printf ("checksum = %d\n", g_8);
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