-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Description
| Bugzilla Link | 2779 |
| Resolution | FIXED |
| Resolved on | Sep 09, 2008 15:54 |
| Version | unspecified |
| OS | Linux |
| CC | @efriedma-quic |
Extended Description
Seen using r55890 on Ubuntu Hardy on ia32. I think the -O1 output is wrong, the loop looks like it has no choice but to execute nearly 2^16 times.
regehr@john-home:/volatile/tmp28$ llvm-gcc -O0 small.c -o small/volatile/tmp28$ ./small
regehr@john-home:
65508
regehr@john-home:/volatile/tmp28$ llvm-gcc -O1 small.c -o small/volatile/tmp28$ ./small
regehr@john-home:
36
regehr@john-home:~/volatile/tmp28$ cat small.c
#include <stdint.h>
#include <stdio.h>
#include <limits.h>
static inline int
lshift_s_s(int left, int right)
{
if ((left < 0)
|| (right < 0)
|| (right >= sizeof(int)CHAR_BIT)
|| (left > (INT_MAX >> right))) {
/ Avoid undefined behavior. */
return left;
}
return left << right;
}
static inline unsigned int
lshift_u_u(unsigned int left, unsigned int right)
{
if ((right >= sizeof(unsigned int)CHAR_BIT)
|| (left > (UINT_MAX >> right))) {
/ Avoid undefined behavior. */
return left;
}
return left << right;
}
int32_t func_8 (uint8_t p_9);
int32_t func_8 (uint8_t p_9)
{
return 1;
}
int32_t func_3 (int8_t p_5);
int32_t func_3 (int8_t p_5)
{
return 1;
}
uint32_t g_19;
void func_1 (void);
void func_1 (void)
{
uint16_t l_2;
for (l_2 = -28; l_2; l_2--)
{
func_3 (
lshift_s_s (l_2,
lshift_u_u (
func_8 (g_19++),
1)
)
);
}
}
int main (void)
{
func_1 ();
printf ("%d\n", g_19);
return 0;
}