[LLVMbugs] [Bug 3455] New: another spurious divide by zero
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sun Feb 1 10:49:27 PST 2009
http://llvm.org/bugs/show_bug.cgi?id=3455
Summary: another spurious divide by zero
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
At -O3, llvm-gcc r63488 on Ubuntu Hardy on x86 turns this program into one that
crashes via divide by zero. If you look at the safe_div macro, it can be seen
that the divide is properly guarded.
#include <stdint.h>
#include <limits.h>
#define safe_div_macro_uint8_t_u_u(ui1,ui2) \
((((uint8_t)(ui2)) == ((uint8_t)0)) \
? ((uint8_t)(ui1)) \
: (((uint8_t)(ui1)) / ((uint8_t)(ui2))))
static uint8_t
safe_div_func_uint8_t_u_u (uint8_t _ui1, uint8_t _ui2)
{
return safe_div_macro_uint8_t_u_u(_ui1,_ui2);
}
#define safe_sub_macro_int64_t_s_s(si1,si2) \
((((((int64_t)(si1))^((int64_t)(si2))) \
& (((((int64_t)(si1)) ^ ((((int64_t)(si1))^((int64_t)(si2))) \
& (((int64_t)1) <<
(sizeof(int64_t)*CHAR_BIT-1))))-((int64_t)(si2)))^((int64_t)(si2)))) <
((int64_t)0)) \
? ((int64_t)(si1)) \
: (((int64_t)(si1)) - ((int64_t)(si2))) \
)
static int64_t
safe_sub_func_int64_t_s_s (int64_t _si1, int64_t _si2)
{
return safe_sub_macro_int64_t_s_s(_si1,_si2);
}
uint32_t g_62;
uint32_t g_116;
int32_t func_57 (uint8_t p_59, uint8_t p_60, uint8_t p_61);
int32_t func_57 (uint8_t p_59, uint8_t p_60, uint8_t p_61)
{
p_59 = (g_62 & p_60) != p_60;
if (safe_div_func_uint8_t_u_u (p_60, p_59))
for (1; 1; 1)
{
}
return 1;
}
void func_52 (void);
void func_52 (void)
{
if (func_57 (1, 1 < (safe_sub_func_int64_t_s_s (g_116, 1)), 1))
{
}
}
int
main (void)
{
func_52 ();
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