-fsanitize=enum false positive with ˜ios::failbit ?

Hi all,

Consider this C++:

I don't think so. Enum values are only defined for the number of bits
needed to represent the type's member values, so if 'x' is a defined
iostate value, then 'x & ~ios::failbit' results in a valid iostate value,
but ~ios::failbit is not itself a valid iostate value.

-Joe

The question is actually about the expression from C++03 27.6.1.3/22:

cin.clear(cin.rdstate() & ~ios::failbit);

C++03 27.4.2 defines iostate and failbit:

typedef T2 iostate;
...
static const iostate failbit;

C++03 27.4.2.1.3 requires iostate to be a bitmask type:

The type iostate is a bitmask type (17.3.2.1.2)

C++03 17.3.2.1.2 requires bitmask types to support ~:

bitmask operator ~(bitmask X)

-Brad

No. This is gcc.gnu.org/PR56158

Sure, but UBSan is telling you that it found a bug in libstdc++'s implementation of operator~ for iostate.

Yes, sorry. I had sent this response well before your first
reply but it was delayed awaiting moderator approval since
I didn't know when sending it that the list is member post
only.

Anyway, thanks for the link to the bug report.

-Brad