https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127486
Bug ID: 127486
Summary: Implicitly zero-initialized hardbool object uses zero
bits instead of its false representation
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bic60176 at gmail dot com
Target Milestone: ---
typedef char __attribute__((__hardbool__(0x5a))) hbool;
static hbool zeroinit;
int main(void)
{
unsigned char rep;
__builtin_memcpy(&rep, &zeroinit, 1);
if (rep != 0x5a)
return 2;
if (zeroinit)
return 3;
return 0;
}
gcc -O0 test.c -o test && ./test
echo $?
Actual: returns 2; storage contains zero.
Expected: returns 0; implicit initialization should produce the declared false
representation 0x5a.