This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiler bug?

I have been previously been using MDK-ARM V4.53 and have recently upgraded to V4.60. When using O2 optimisation I started getting a compiler "may be used before being set" warning that I never got with V4.53. I have provide some demo code below. In my view this is a compiler bug - do you agree?

typedef struct
{
    unsigned int a : 2;
    unsigned int b : 2;
} TEST1;

TEST1 test1_global;


typedef struct
{
    unsigned int a;
    unsigned int b;
} TEST2;

TEST2 test2_global;


int main( void )
{
    TEST1 test1_local;
    TEST2 test2_local;

    // the following gives "warning: C3017W: test1_local may be used before being set"
    test1_local.a = 1;
    test1_local.b = 1;
    test1_global = test1_local;

    // the following is OK
    test2_local.a = 1;
    test2_local.b = 1;
    test2_global = test2_local;


    return 0;
}

0