jingoro2112 / wrench

practical embedded script interpreter
MIT License
106 stars 9 forks source link

Can't build due to possibly uninitialized value #2

Closed Diegovsky closed 1 year ago

Diegovsky commented 1 year ago

When building, I get the following message:

g++  -MD -Wall -Werror -O3  -I. -c -o objs_linux/cc.o discrete_src/cc.cpp
g++  -MD -Wall -Werror -O3  -I. -c -o objs_linux/operations.o discrete_src/operations.cpp
discrete_src/operations.cpp: In function ‘void doAssign_X_E(WRValue*, WRValue*)’:
discrete_src/operations.cpp:350:46: error: ‘element.WRValue::<anonymous>.WRValue::<unnamed union>::<anonymous>.WRValue::<unnamed union>::<unnamed struct>::type’ may be used uninitialized [-Werror=maybe-uninitialized]
  350 |                 wr_assign[(WR_EX<<2)+element.type](to, &element);
      |                                      ~~~~~~~~^~~~
discrete_src/operations.cpp:348:25: note: ‘element’ declared here
  348 |                 WRValue element;
      |                         ^~~~~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:47: objs_linux/operations.o] Error 1

Repo commit: 8c0447b g++ version: g++ (GCC) 12.2.0

jingoro2112 commented 1 year ago

It was indeed possible if a default case was reached for the element to go uninitialized. In practice it "can't happen" but now it really can't. fixed in latest

Diegovsky commented 1 year ago

Thank you :)