https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67433
--- Comment #12 from xuejuncao <xuejuncao at gmail dot com> --- (In reply to Richard Biener from comment #11) > (In reply to xuejuncao from comment #10) > > when bool value read from unpacked stream or file, wen can not ensure it's 1 > > or 0; > > so maybe the best solution is compile with "-D_Bool=char" for now :-/ > > You can always do the read with 'char' and then convert to _Bool. > > You can also "fix" your testcase (I think, didn't try) by using > > union u { > bool b : 1; > char c; > } u; > > (in case unions allow bitfield members) yes, it works, but likes a trick:-) bit operation to bool is also undefined int i = (u.b & 1 ? 1 : 0); // works without -O2, useless with -O2