Menu ▾ ▴

#2152 no report "error 158: overflow in implicit constant conversion"

closed-fixed
None
PIC14
5
2026-10-20
2013-04-03
No

the compiler does not generate an overflow error constants.

$cat bug5.c

#include <pic16f877a.h>
#include <stdint.h>

#define DIV_idelay ((uint16_t)4*16*256)
#define delay_mstoi(time) ((((int32_t)(F_CPU))*(time)+((int32_t)1000*DIV_idelay/2))/ ((int32_t)1000*DIV_idelay))

uint8_t tmp8;
uint16_t tmp16;

void main(void) {
    //error 158: overflow in implicit constant conversion
    tmp8=delay_mstoi(3000);
    tmp16=delay_mstoi(3000);
}
$ sdcc --Werror -pp16f877a --opt-code-size -Ilibmain -DF_CPU=4000000 -mpic14 --use-non-free bug5.c
message: using default linker script "/usr/local/share/gputils/lkr/16f877a_g.lkr"
$ sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jul  6 2012) (Linux)
1 Attachments

Related

Bugs: #3094

Discussion

  • Sergey Belyashov

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
     the compiler does not generate an overflow error constants.
    
    -$cat bug5.c
    +`$cat bug5.c`
    +```
     #include &lt;pic16f877a.h&gt;
     #include &lt;stdint.h&gt;
    
    @@ -15,8 +16,10 @@
         tmp8=delay_mstoi(3000);
         tmp16=delay_mstoi(3000);
     }
    -
    +```
    +```
     $ sdcc --Werror -pp16f877a --opt-code-size -Ilibmain -DF_CPU=4000000 -mpic14 --use-non-free bug5.c
     message: using default linker script &#34;/usr/local/share/gputils/lkr/16f877a_g.lkr&#34;
     $ sdcc -v
     SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jul  6 2012) (Linux)
    +```
    
     
  • Christopher Bazley

    • assigned_to: Christopher Bazley
     
  • Christopher Bazley

    Both assignments in the original PIC14 attachment now get diagnostic 158 with the reported --Werror and F_CPU settings.

    https://godbolt.org/z/9qYYshKbT

     
  • Christopher Bazley

    • status: open --> closed-fixed
     
  • Christopher Bazley

    Added regression test in [r17048]

     

    Related

    Commit: [r17048]


Log in to post a comment.