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

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> That said, I wonder if it is ok that we don't reject clear out of bound
> POINTER_PLUS_EXPR in constexprs, like:
> static constexpr const char foo[] = "foo";
> static constexpr const char *bar = "bar";
> 
> static_assert (foo < foo + 30, "check");
> static_assert (foo != foo + 30, "check");
> static_assert (bar <= bar + 30, "check");
> static_assert (bar != bar + 30, "check");
> 
> But that is preexisting, the patch doesn't really change anything on that,
> and most likely we want to handle this in the FE (if at all).

Those should all be rejected in the static_assert because they are not core
constant expressions as a result of the undefined behavior in the pointer
arithmetic.  Bug 70151 tracks this defect.

Reply via email to