- Category: Preprocessor --> PIC14
sdcc -v
SDCC : pic14 3.2.1 #8547 (Apr 23 2013) (Linux)
Hello,
I made a little example to show my problem, if a variable isn't initialized. There is an increment inside an if() condition which generates wrong code in a special case. So the result is the address of the corresponding variable increased by the given value and not the value increased by this number.
The result is similar if the variable type is char.
Altough the compiler gives warning if the variable isn't initialized I think this is a bug because I use many times averaging of a large number of samples from ADC ( and similar ) and there is no matter when the accumulated number isn't initialized.
Here is the warning about the uninitialized variable:
okoska.c:35: warning 84: 'auto' variable 'anything' may be used before initialization
And the command generated the code by:
sdcc --use-non-free -mpic14 -p16f628a -V --debug -I/home/zsolti/okoska_01/ -c okoska.c
.line 37; "okoska.c" anything += 2;
MOVLW (_main_anything_1_5 + 2)
;; >>> genarith.c:296:genAddLit
;; popGet AOP_PCODE (PO_DIR + 0) 1130 _main_anything_1_5
MOVWF _main_anything_1_5
;; >>> genarith.c:295:genAddLit
;; popGet AOP_PCODE (PO_DIR + 3) 1130 _main_anything_1_5
MOVLW (_main_anything_1_5 + 3)
;; >>> genarith.c:296:genAddLit
;; popGet AOP_PCODE (PO_DIR + 1) 1130 _main_anything_1_5
MOVWF (_main_anything_1_5 + 1)