[Bug c++/109232] Using deduced return type in an unevaluated context leads to codegen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232 --- Comment #5 from Patrick Palka --- So one workaround is to explicitly declare begin inline, which works because the problematic test in cgraph_node::finalize_function excludes DECL_DECLARED_INLINE_P functions.
[Bug c++/109232] Using deduced return type in an unevaluated context leads to codegen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232 --- Comment #4 from Patrick Palka --- Here's another perhaps simpler version that explicitly gives begin internal linkage, which also fails to link: namespace { template auto begin(T&& r) { return r.begin(); } } struct R { int* begin(); }; static_assert(__is_same(decltype(begin(R())), int*)); int main() { }
[Bug c++/109232] Using deduced return type in an unevaluated context leads to codegen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232 Patrick Palka changed: What|Removed |Added CC||ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka --- What seems to be happening is determine_visibility correctly notices that begin should have internal linkage due to R having internal linkage, so it proceeds to clear TREE_PUBLIC, DECL_COMDAT, DECL_EXTERN, etc for begin. Later in cgraph_node::finalize for begin, we force its definition to be outputted due to /* When not optimizing, also output the static functions. (see PR24561), but don't do so for always_inline functions, functions declared inline and nested functions. These were optimized out in the original implementation and it is unclear whether we want to change the behavior here. */ if (((!opt_for_fn (decl, optimize) || flag_keep_static_functions || node->no_reorder) && !node->cpp_implicit_alias && !DECL_DISREGARD_INLINE_LIMITS (decl) && !DECL_DECLARED_INLINE_P (decl) && !(DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)) node->force_output = 1; I guess we need to somehow refine the above test to exclude implicit instantiations with internal linkage?
[Bug c++/109232] Using deduced return type in an unevaluated context leads to codegen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232 --- Comment #2 from Andrew Pinski --- clang does not emit the function but does emit the warning ...
[Bug c++/109232] Using deduced return type in an unevaluated context leads to codegen
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232 Richard Biener changed: What|Removed |Added Keywords||link-failure --- Comment #1 from Richard Biener --- maybe it's implementation defined or unspecified whether instantiation happens?