On 15/09/2020 09:57, Jakub Jelinek via Gcc-patches wrote:
The following testcase is miscompiled (in particular the a and i
initialization).  The problem is that build_special_member_call due to
the immediate constructors (but not evaluated in constant expression mode)
doesn't create a CALL_EXPR, but returns a TARGET_EXPR with CONSTRUCTOR
as the initializer for it, and then expand_default_init just emits
the returned statement, but this one doesn't have any side-effects and does
nothing.  There is an if to handle constexpr ctors which emits an INIT_EXPR
but constexpr ctors still show up as CALL_EXPR and need to be manually
evaluated to constant expressions (if possible).

The following patch fixes that, though I'm not sure about several things.
One is that the earlier if also has expr == true_exp && in the condition,
not sure if we want it in this case or not.
Another is that for delegating constructors, we emit two separate calls
and build_if_in_charge them together.  Not sure if consteval could come into
play in that case.

(Just reporting that with this patch applied, my build of LibreOffice using consteval, cf. <https://git.libreoffice.org/core/+/4b9e440c51be3e40326bc90c33ae69885bfb51e4%5E!/> "Turn OStringLiteral into a consteval'ed, static-refcound rtl_String", works fine.)

Reply via email to