[PATCH] D72242: Fix crash on value dependent bitfields in if conditions in templates

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 18:58:36 PST 2020


rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

This is not an appropriate fix; the code is locally correct. The right way to handle this is exactly what Clang currently does: if the expression is not type-dependent, then contextually convert to `bool`, and if it's not value-dependent, then make sure it's a constant expression.

The bug is that we should treat the name of a bit-field with a value-dependent width as being type-dependent -- the `c` expression in the testcase should be a type-dependent expression (even though its type is known to be `int`) because we don't know how to promote it due to the value-dependent bit-width. (This is ultimately a bug in the C++ standard, which fails to provide such a rule, but I've reported that to the committee and it should be fixed in the standard at some point. But the right fix seems obvious enough that we can just do it.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72242/new/

https://reviews.llvm.org/D72242





More information about the cfe-commits mailing list