https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110348

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> I agree with your WIP patch. The requirements for data() and size() to be
> constant expressions are in p11 (11.2) which only apply if the static
> assertions fails.

In other words, I think the paper is clear and clang is wrong here.

Although arguably what clang does is more useful. I'm not sure why you'd want
to use a non-constexpr size() or data() that only compiles as long as the
static assertion passes. It means you won't find out that your user-generated
message can't actually be printed until you run on a target where the assertion
fails.

I suppose there could be a case where those functions are only constexpr
sometimes, and that happens to coincide with exactly the conditions where the
assertion fails. That seems unlikely though. It seems more likely that you
would use an assertion to terminate compilation when your code is *missing*
features, not make it fail only when features are present.

The wording voted into the draft also seems counter to the design expressed in
the paper that says "The message-producing expression is intended to be always
instantiated, but only evaluated if the assertion failed." Does instantiating
it require it to be a valid constant expression, even if not evaluated?

Reply via email to