[Bug c++/85944] Address of temporary bound to a function parameter at global scope not considered constexpr

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 25 15:59:39 GMT 2022


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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'm afraid the middle-end can't do here much.
maybe_nonzero_address handles file scope vars (vars in symbol table) and
automatic vars, but for the TARGET_EXPR temporaries created by
force_target_expr -> build_local_temp if they are built outside of the function
it doesn't know anything about them until they are gimplified.  They are
artificial VAR_DECLs with NULL DECL_CONTEXT, their DECL_CONTEXT will be set
only
during gimplification when the static ctors function is created.

So, either we'd need to mark such local temporaries some way that
maybe_nonzero_address could assume that while they don't look like automatic
vars yet, they will be ones later on (special attribute, or flag, etc.), or
constexpr.cc would need to handle folding those cases itself.


More information about the Gcc-bugs mailing list