Skip to content

likely integer codegen bug #2851

@regehr

Description

@regehr
Bugzilla Link 2479
Resolution FIXED
Resolved on Jun 21, 2008 19:23
Version unspecified
OS Linux
CC @efriedma-quic

Extended Description

This happens with svn 52513 on ubuntu feisty on ia32.

Unfortunately I have not been able to further reduce the test input.

[regehr@babel tmp21]$ llvm-gcc -O2 -fwrapv small.c -o small
[regehr@babel tmp21]$ ./small
0
[regehr@babel tmp21]$ llvm-gcc -O3 -fwrapv small.c -o small
[regehr@babel tmp21]$ ./small
1

#include <stdint.h>
#include <limits.h>
#include <stdio.h>

static inline unsigned long int
mod_rhs(const long int rhs)
{
if (rhs == 0) return 1;
return rhs;
}

static inline int
rshift_s_s(int left, int right)
{
if ((left < 0)
|| (right < 0)
|| (right >= sizeof(int)CHAR_BIT)) {
/
Avoid implementation-defined and undefined behavior. */
return left;
}
return left >> right;
}

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;
}

uint32_t g_2;
uint32_t g_3 = 0x00252604L;

int32_t func_10 (int8_t p_12);
int32_t func_10 (int8_t p_12)
{
int32_t l_14 = 1;
uint16_t l_26;
uint32_t l_15 = 1;
if ((l_14 || l_15) % mod_rhs (1 < p_12))
for (0; l_26; l_26 -= 1)
{
}
return 1;
}

void func_1 (void);
void func_1 (void)
{
int8_t l_4 = 0x18L;
int32_t l_5 = 1;
uint16_t l_6 = 1;
uint32_t l_7 = 1;
uint32_t l_8 = 1;
g_2 =
((((g_3 ^ l_4) <= (1 % mod_rhs (1)) && l_4)
&& (g_3 > (l_6 && 1))) != (((rshift_s_s (l_5, 1))
|| (l_7 && g_3) <= (l_6 && g_2)) - ((l_8
&& l_5)
%
mod_rhs
(lshift_s_s
((1 <
l_6),
func_10
(g_3))))));
}

int
main (void)
{
func_1 ();
printf ("%d\n", g_2);
return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions