[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csmith-bugs] pragma pack and unions



Hello,

The attached program exhibits the issue described in a previous thread
for one of the elements of g_85 (of type union U5):
http://www.flux.utah.edu/listarchives/csmith-dev/msg00208.html

It was generated with version 9a88a2.

Pascal

cuoq@lsl-cloud:~/csmith_new$ ~/gcc-172652/bin/gcc -Iruntime t.c
t.c:76:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:77:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:79:15: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:79:15: warning: overflow in implicit constant conversion [-Woverflow]
t.c:90:21: warning: overflow in implicit constant conversion [-Woverflow]
t.c:90:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:90:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:90:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:90:21: warning: overflow in implicit constant conversion [-Woverflow]
t.c:94:15: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:100:1: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:103:20: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:121:14: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c: In function ‘func_1’:
t.c:149:12: warning: overflow in implicit constant conversion [-Woverflow]
t.c:149:12: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:149:12: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:149:12: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:149:12: warning: overflow in implicit constant conversion [-Woverflow]
t.c:149:12: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:150:11: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:161:11: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:175:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:175:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:175:16: warning: overflow in implicit constant conversion [-Woverflow]
t.c:178:16: warning: overflow in implicit constant conversion [-Woverflow]
t.c:178:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:178:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:178:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
t.c:178:16: warning: overflow in implicit constant conversion [-Woverflow]
t.c:209:19: warning: large integer implicitly truncated to unsigned type [-Woverflow]
cuoq@lsl-cloud:~/csmith_new$ ./a.out 
checksum = C98A56F0
cuoq@lsl-cloud:~/csmith_new$ clang -Iruntime t.c
cuoq@lsl-cloud:~/csmith_new$ ./a.out 
checksum = C982B518
cuoq@lsl-cloud:~/csmith_new$ 

/*
 * This is a RANDOMLY GENERATED PROGRAM.
 *
 * Generator: csmith 2.1.0
 * Git version: 7e33250
 * Options:   --max-array-dim 2 --max-array-len-per-dim 3 --max-funcs 2 --no-unions --max-struct-fields 2 --no-jumps --no-pointers --no-volatiles --no-argc
 * Seed:      3850583756
 */

#include "csmith.h"


static long __undefined;

/* --- Struct/Union Declarations --- */
struct S0 {
   uint32_t  f0;
};

/* --- GLOBAL VARIABLES --- */
static int32_t g_2 = (-9L);
static struct S0 g_16[3] = {{4294967295U}, {4294967295U}, {4294967295U}};
static uint8_t g_17[2][3] = {{0x89L, 0x89L, 0x89L}, {0x89L, 0x89L, 0x89L}};
static int32_t g_19 = 7L;
static uint64_t g_22 = 0x38D06721F7D96711LL;
static uint8_t g_26 = 0xCBL;
static const uint32_t g_93 = 0x60138ADDL;
static int8_t g_96 = (-3L);


/* --- FORWARD DECLARATIONS --- */
static uint32_t  func_1(void);
static uint32_t  func_10(uint16_t  p_11, uint8_t  p_12, int16_t  p_13, const uint16_t  p_14);


/* --- FUNCTIONS --- */
/* ------------------------------------------ */
/* 
 * reads : g_2 g_17 g_22 g_16 g_19 g_26 g_93 g_96
 * writes: g_2 g_16 g_19 g_22 g_26 g_96
 */
static uint32_t  func_1(void)
{ /* block id: 0 */
    const int32_t l_7 = (-1L);
    uint16_t l_34[2][3] = {{0x3592L, 3U, 0x3592L}, {0x3592L, 3U, 0x3592L}};
    int32_t l_36 = 0xA626AECEL;
    struct S0 l_68 = {0x25FC6431L};
    int i, j;
    for (g_2 = 0; (g_2 != 24); g_2 = safe_add_func_int16_t_s_s(g_2, 5))
    { /* block id: 3 */
        uint32_t l_18[1];
        int32_t l_32[3] = {5L, 0xCECB2EC6L, 5L};
        int32_t l_45 = 0L;
        int16_t l_47 = 0xE4BCL;
        int32_t l_48 = 2L;
        int i;
        for (i = 0; i < 1; i++)
            l_18[i] = 0xD816F93BL;
        if ((safe_mul_func_int16_t_s_s(l_7, ((((safe_div_func_uint32_t_u_u((g_2 | g_2), func_10(l_7, g_2, g_2, g_2))) < ((g_17[0][1] != g_17[0][1]) < 1L)) & g_17[1][1]) & l_18[0]))))
        { /* block id: 7 */
            uint32_t l_27 = 0x9B95520FL;
            if ((g_2 | g_2))
            { /* block id: 8 */
                uint8_t l_25 = 0x4BL;
                for (g_19 = (-3); (g_19 >= 19); g_19 = safe_add_func_uint16_t_u_u(g_19, 1))
                { /* block id: 11 */
                    g_22 ^= 0L;
                    for (g_22 = 0; (g_22 <= 1); g_22 += 1)
                    { /* block id: 15 */
                        int i;
                        g_16[(g_22 + 1)] = g_16[(g_22 + 1)];
                        g_26 ^= (safe_mul_func_uint16_t_u_u((((0x9F48L <= 3L) && l_25) >= g_2), g_19));
                    }
                }
                if (l_27)
                    continue;
            }
            else
            { /* block id: 21 */
                const int64_t l_33 = 0xCC0C7FD579DEB476LL;
                int32_t l_35 = 1L;
                struct S0 l_42 = {5U};
                if ((safe_rshift_func_int16_t_s_u((((l_7 && (func_10(l_32[2], g_16[2].f0, g_16[2].f0, l_33) && (l_33 < l_34[1][1]))) || (0x5CF455DBFE6B87C2LL >= g_19)) == g_2), 14)))
                { /* block id: 22 */
                    return g_19;
                }
                else
                { /* block id: 24 */
                    const uint16_t l_39 = 65535U;
                    if (g_2)
                        break;
                    l_36 ^= l_35;
                    g_19 = ((safe_mul_func_uint16_t_u_u(g_19, l_39)) ^ ((safe_lshift_func_uint8_t_u_u(g_26, 5)) == g_17[0][1]));
                    g_16[1] = g_16[2];
                }
                for (g_22 = 0; (g_22 <= 1); g_22 += 1)
                { /* block id: 32 */
                    int i, j;
                    g_19 = g_17[g_22][(g_22 + 1)];
                }
                l_42 = g_16[2];
                for (g_26 = 22; (g_26 == 12); g_26 = safe_sub_func_int16_t_s_s(g_26, 2))
                { /* block id: 38 */
                    if (g_26)
                        break;
                    if (g_17[1][1])
                        break;
                }
            }
            l_45 = g_26;
            g_16[2] = g_16[2];
        }
        else
        { /* block id: 45 */
            int16_t l_46 = (-7L);
            g_19 = (l_46 == l_46);
            if (l_34[1][1])
            { /* block id: 47 */
                l_48 &= ((0U >= (l_47 >= g_22)) > l_45);
                l_48 = (safe_mod_func_uint8_t_u_u(l_46, l_7));
            }
            else
            { /* block id: 50 */
                uint32_t l_51 = 4294967295U;
                if (l_51)
                { /* block id: 51 */
                    uint64_t l_62 = 0x27FB601BA2AAC5DALL;
                    int8_t l_63 = 0xB8L;
                    l_63 = ((safe_sub_func_uint64_t_u_u(l_32[2], (l_51 == (safe_sub_func_uint16_t_u_u(l_36, 0xB454L))))) | ((safe_rshift_func_uint16_t_u_u((safe_mod_func_uint16_t_u_u(0U, 5L)), (+(safe_div_func_uint32_t_u_u(l_62, func_10(g_17[1][0], g_16[2].f0, l_34[1][1], g_19)))))) && (+g_16[2].f0)));
                }
                else
                { /* block id: 53 */
                    g_19 = (g_19 != (safe_sub_func_uint16_t_u_u(g_22, (g_2 ^ 9L))));
                }
            }
        }
        for (l_47 = 0; (l_47 >= (-13)); l_47 = safe_sub_func_int64_t_s_s(l_47, 3))
        { /* block id: 60 */
            int64_t l_74 = 0xCAC8A3317083D4BALL;
            uint32_t l_92 = 0U;
            g_16[1] = l_68;
            if ((safe_lshift_func_int16_t_s_s(g_17[1][0], (safe_div_func_uint8_t_u_u(func_10((safe_unary_minus_func_uint8_t_u((2U != 7U))), (0x40L == (l_74 != l_7)), ((safe_sub_func_int64_t_s_s(0x1A330C13F5ED5A8DLL, (g_19 >= g_26))) || func_10(l_68.f0, g_19, g_26, g_2)), l_45), g_17[0][2])))))
            { /* block id: 62 */
                struct S0 l_79 = {0U};
                for (g_26 = 0; (g_26 != 16); g_26 = safe_add_func_uint16_t_u_u(g_26, 5))
                { /* block id: 65 */
                    l_79 = g_16[1];
                }
                if (g_26)
                    break;
                g_19 |= (safe_div_func_uint8_t_u_u((safe_rshift_func_int16_t_s_s((l_74 >= ((0x7EC325DF25B48F27LL > 0x978B3CF7409415F9LL) <= ((l_79.f0 <= l_32[2]) | g_16[2].f0))), 5)), l_36));
                for (g_19 = 0; (g_19 >= (-15)); g_19 = safe_sub_func_uint8_t_u_u(g_19, 9))
                { /* block id: 72 */
                    uint32_t l_88 = 0xD2C718CAL;
                    int64_t l_89 = 0L;
                    l_48 |= (g_22 || g_26);
                    g_96 = ((safe_div_func_uint64_t_u_u((func_10(func_10(l_88, l_18[0], l_89, l_89), (l_74 >= (safe_rshift_func_int8_t_s_s(l_89, l_89))), g_26, ((l_92 != g_17[0][0]) <= (l_89 < l_79.f0))) > g_93), (6U || (safe_mod_func_uint64_t_u_u(0U, g_17[0][1]))))) > l_92);
                }
            }
            else
            { /* block id: 76 */
                struct S0 l_97 = {0x5FA5926FL};
                l_97 = g_16[0];
            }
            g_16[2] = g_16[1];
            for (l_92 = 0; (l_92 >= 45); l_92 = safe_add_func_uint32_t_u_u(l_92, 3))
            { /* block id: 82 */
                for (l_48 = (-26); (l_48 == (-10)); l_48 = safe_add_func_int8_t_s_s(l_48, 1))
                { /* block id: 85 */
                    for (l_74 = 0; (l_74 > (-8)); l_74 = safe_sub_func_int32_t_s_s(l_74, 1))
                    { /* block id: 88 */
                        return g_17[0][0];
                    }
                }
                l_45 ^= g_96;
            }
        }
        for (l_48 = 0; (l_48 < 28); l_48 = safe_add_func_int8_t_s_s(l_48, 1))
        { /* block id: 97 */
            struct S0 l_106 = {4294967287U};
            g_16[2] = l_106;
        }
        if (l_47)
            break;
    }
    return l_68.f0;
}


/* ------------------------------------------ */
/* 
 * reads : g_2
 * writes: g_16
 */
static uint32_t  func_10(uint16_t  p_11, uint8_t  p_12, int16_t  p_13, const uint16_t  p_14)
{ /* block id: 4 */
    struct S0 l_15 = {0x6A927213L};
    g_16[2] = l_15;
    return g_2;
}




/* ---------------------------------------- */
int main (void)
{
    int i, j;
    int print_hash_value = 0;
    platform_main_begin();
    crc32_gentab();
    func_1();
    transparent_crc(g_2, "g_2", print_hash_value);
    for (i = 0; i < 3; i++)
    {
        transparent_crc(g_16[i].f0, "g_16[i].f0", print_hash_value);
        if (print_hash_value) printf("index = [%d]\n", i);

    }
    for (i = 0; i < 2; i++)
    {
        for (j = 0; j < 3; j++)
        {
            transparent_crc(g_17[i][j], "g_17[i][j]", print_hash_value);
            if (print_hash_value) printf("index = [%d][%d]\n", i, j);

        }
    }
    transparent_crc(g_19, "g_19", print_hash_value);
    transparent_crc(g_22, "g_22", print_hash_value);
    transparent_crc(g_26, "g_26", print_hash_value);
    transparent_crc(g_93, "g_93", print_hash_value);
    transparent_crc(g_96, "g_96", print_hash_value);
    platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
    return 0;
}

/************************ statistics *************************
XXX max struct depth: 1
breakdown:
   depth: 0, occurrence: 26
   depth: 1, occurrence: 7
XXX total union variables: 0

XXX max expression depth: 1
breakdown:
   depth: 0, occurrence: 30
   depth: 1, occurrence: 5

XXX total number of pointers: 0

XXX times a non-volatile is read: 119
XXX times a non-volatile is write: 37
XXX times a volatile is read: 0
XXX    times read thru a pointer: 0
XXX times a volatile is write: 0
XXX    times written thru a pointer: 0
XXX times a volatile is available for access: 0
XXX percentage of non-volatile access: 100

XXX forward jumps: 0
XXX backward jumps: 0

XXX stmts: 103

XXX percentage a fresh-made variable is used: 25.6
XXX percentage an existing variable is used: 74.4
********************* end of statistics **********************/