#449 fail to promote to int or'ing constants

closed
None
5
2003-02-01
2003-02-01
No

/* bug, fails to pass MSB of parameter */

unsigned int gw1;

void our_word(unsigned int w1) {
gw1 = w1;
}

void main(void)
{
our_word(1 | (1 << 7) ); // ok
our_word(2 | (1 << 8) ); // bad, passes 2
our_word(3 | ( ((unsigned int)(1)) << 8) ); // bad,
passes 3
our_word(3 | (1 * 256) ); // bad, passes 3
our_word(3 | 256 ); // bad, passes 3
our_word(3 | 1024 ); // bad, passes 3
our_word(((unsigned int)(3)) | 1024 ); // ok
}

Discussion

  • Johan Knol

    Johan Knol - 2003-02-01
    • assigned_to: nobody --> johanknol
    • status: open --> closed
     
  • Johan Knol

    Johan Knol - 2003-02-01

    Logged In: YES
    user_id=63512

    fixed in SDCCval.c:1.58

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks