mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
94 stars 70 forks source link

CHOICE_decode_aper: 'value' may be used uninitialized [-Wmaybe-uninitialized] #98

Closed pespin closed 2 years ago

pespin commented 2 years ago

When compiling osmo-cbc.git branch pespin/sbcap, which contains mouse07410/asn1c generated code (asn1c.git current vlm_master, 30219de2d3da888b4f1eea0dd79f2a505000401a).

git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c: In function 'CHOICE_decode_aper':
git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c:67:44: warning: 'value' may be used uninitialized [-Wmaybe-uninitialized]
   67 |         value = specs->from_canonical_order[value];
      |                                            ^
git/osmo-cbc/src/sbcap/gen/constr_CHOICE_aper.c:21:9: note: 'value' was declared here
   21 |     int value;
      |         ^~~~~
 $ gcc --version
gcc (GCC) 12.1.0
pespin commented 2 years ago

Not sure what's the proper fix here. Looks like "value" is indeed being used initialized at least if "ct == NULL", and maybe also in other cases where ct != NULL.

mouse07410 commented 2 years ago

I think this is simple to take care of, so pushing the fix.

pespin commented 2 years ago

A regression was introduced with your commit, fix available here: https://github.com/mouse07410/asn1c/pull/104/commits/7e1371ab5016adfa1d3199eec9307246f7a85942