[PATCH 2/9] Use unsigned as base type for some enums

Tom Tromey tom@tromey.com
Mon Aug 27 20:22:00 GMT 2018


>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

Simon> Can you give an example of how the error manifests itself (I'm not really
Simon> familiar with -fsanitize=undefined).  Is the error reported at compile-time
Simon> or run-time?  I'm not able to make a synthetic standalone example to reproduce
Simon> the error.

You will get an error at runtime, and with the flags added by the last
patch in the series, a crash.

The error looks somewhat like the error from the expression dumping
patch:

  runtime error: load of value 2887952, which is not a valid value for type 'exp_opcode'

(I don't have an exact error handy, this was just taken from the other
patch.)

Simon> In any case, that LGTM if that makes the compiler happy.  If the error reported
Simon> by -fsanitize=undefined is at run-time, could we add a static assert in there
Simon> to make sure the underlying types of types used with DEF_ENUM_FLAGS_TYPE are
Simon> unsigned, to get a compilation error?

With the final patch, any UB will cause gdb to crash (in development
mode), presumably leading to a test suite failure.  I think it isn't
necessary to require unsigned as the underlying type -- any type will
do.  However I don't know how to assert that.

Tom



More information about the Gdb-patches mailing list