Skip to main content
Visitor II
April 9, 2010
Question

COSMIC CXSTM8 - problem with if-else statemant

  • April 9, 2010
  • 7 replies
  • 863 views
Posted on April 09, 2010 at 16:58

COSMIC CXSTM8 - problem with if-else statemant

    This topic has been closed for replies.

    7 replies

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:07

    Hi,

    we confirm this is a problem in the compiler, please contact me via email (luca.ubiali@cosmic.fr) for the solution.

    Regards,

    Luca (Cosmic)

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:07

    Hi again,

    please disregard my previous message (internal misunderstanding): actually we cannot reproduce your error.

    Can you please send me the minimun compilable code showing the problem together with the detailed info on the version you are using?

    Regards,

    Luca (Cosmic)

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:07

    Hi Luca,

    thanks for the promt reply. I  took your remarks as suggestion to start further studying - so there are new findings:

    Now I'm sure, that the malfunction arises from the fact, that I define the structure as volatile:

    @tiny volatile struct  flag_type  flag;

    Hope this information will be helpful to you.

    Regards,

    WoRo

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:08

    Hello,

    we still cannot see the error.

    Here is what we tried:

    #define N 1

    @tiny volatile struct x {

        char b0:N, b1:N, b2:N;

        } x;

    void f(void)

        {

        if ((x.b0 = x.b1) == 1)

            x.b2 = 0;

        }

    please send us a complete example.

    Regards,

    Luca

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:08

    Hi Luca,

    here my minimised program attached.

    Regards,

    WoRo

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:08

    Hi again,

    new findings:

    Modifying your example strictly according to the rules of ANSI C, the CX educes the known malfunction.

    #define N 1

    @tiny volatile struct x {

        unsigned int b0:N, b1:N, b2:N, b3:N,

             b4:N, b5:N, b6:N, b7:N, b8:N;

        } x;

    void f(void)

        {

        if ((x.b0 = x.b1) == 1)

            x.b2 = 0;

        } Where using (unsigned) int instead of char -PLUS- a structure of more than 8bits seems to cause the failure.

    Regards, WoRo

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:08

    Hi Woro,

    we fixed the problem, thank you for your analysis.

    Regards,

    Luca