This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/82186] [7/8 Regression] ICE (segfault), VLA type with inlining
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 01 Dec 2017 18:57:43 +0000
- Subject: [Bug c/82186] [7/8 Regression] ICE (segfault), VLA type with inlining
- Auto-submitted: auto-generated
- References: <bug-82186-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82186
--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
For C, what is supposed to happen is that every call to groktypename where
there might be side effects from the type name passes a non-null EXPR
argument, and then the caller arranges for evaluation of expression stored
in *EXPR at an appropriate point, if the language semantics mean it should
be evaluated. For example, c_cast_expr creates a C_MAYBE_CONST_EXPR which
is meant to ensure the expressions required for the type being cast to are
evaluated before the cast itself; sizeof handling ensures the expression
is only evaluated if the type is a VLA, not e.g. a pointer to VLA.
The evaluation has the happen at the right point within the containing
expression, e.g. in
(foo = bar (), (int (*)[foo = baz ()]) something)
the expression foo = baz () in the type name has to be evaluated after foo
= bar ().
Note that there are cases where the size expression may never be evaluated
- if the type of a conditional expression involves a VLA size expression
from an unevaluated half of that conditional expression. In that case,
there is undefined behavior at runtime (but as usual the compiler still
needs to accept that code, since whether the expression is evaluated is a
property of a particular execution of the program). See C99 DR#342 and
C99 DR#340.