Menu

#3094 ulong2fs gives incorrect warning 158 overflow in implicit constant conversion

open
nobody
None
Front-end
5
2023-01-31
2020-07-31
No

When building the libraries SDCC emits a lot of warnings 158: overflow in implicit constant conversion for _ulong2fs.c line 85. At this line however is no overflow as far as I can see.

#define EXCESS          126
unsigned char exp = 24 + EXCESS;

It is of course simple to suppress this warning here, but it should not be given in the first place.

Related

Wiki: SDCC-STD-UX

Discussion

  • Philipp Klaus Krause

    It is one of those annoying type optimizations on AST. Both 24 and EXCESS end up as signed char (since the optimization sees that they fit into one), then the result is also made a signed char, which is negative, so we get an overflow when casting that to the final unsigned char.

     

Log in to post a comment.