[cfe-dev] Possibly invalid enum tautology warning
David Blaikie
dblaikie at gmail.com
Mon Aug 8 09:31:21 PDT 2011
>> enum tester { A = 0, B };
Ah, I missed this bit. But I suspect that even without this ("= 0")
you'd get the same behavior - at that point I'd be more inclined to
consider Peter's position, assuming it's possible that a compliant
implementation could use A = -1, B = 0, for example.
If it's guaranteed that unspecified enum values start at zero, and as
has been implied/mentioned, assigning an enum does have UB when
assigned outside the range of enumerated values (much like wedging 2
into a bool produces crazy) then, yes, this warning seems totally fine
to me. It's not complete, of course, but it's not wrong either.
More information about the cfe-dev
mailing list