https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119109
Stian Halseth <stian at itx dot no> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |stian at itx dot no
--- Comment #6 from Stian Halseth <stian at itx dot no> ---
I had a look at this on sparc64-linux with master (1c6bee45b).
basic_string is 24 bytes, and sparc64 returns that in registers.
check_return_expr in cp/typeck.cc takes the "We can't initialize a
register from a AGGR_INIT_EXPR" branch. With -std=c++17
-fdump-tree-original f() becomes
return <retval> = TARGET_EXPR <D.2127, aggr_init_expr ...>, D.2127;
The constexpr evaluator follows that copy, so _M_p points into
D.2127._M_local_buf and the initializer isn't a constant expression. On
x86_64 the struct is returned in memory and the TARGET_EXPR initializes
<retval> directly.
That's the same branch H.J. found for -mx32 in PR120409 comment 11, and
pr119916.C fails on sparc64 the same way. There the copy is allowed at
run time, but here it makes constant evaluation depend on how the
target returns structs.