From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 968833858D37; Tue, 21 Mar 2023 13:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 968833858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679404552; bh=/d0TNtjckN73Lt+truNFCZIaUpCDBfZXpCp4n3AJGto=; h=From:To:Subject:Date:From; b=cA8KUgakRswNEXTjdNY33vUgEQsDnTRghL3hIlLNXdDqgsQvSIyLWFbywek2bRybv aYg0Pn8u4e6oxgKdeyMSE0ekKK1ND8ofWFT+5F9HmcqHjB+1wrF1Jnx4+dq9vOxaJY 5wYhFu4twRuECPacmlfIoESBguPRL+5soZYILuUY= From: "rs2740 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109232] New: Using deduced return type in an unevaluated context leads to codegen Date: Tue, 21 Mar 2023 13:15:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rs2740 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109232 Bug ID: 109232 Summary: Using deduced return type in an unevaluated context leads to codegen Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- auto begin(auto&& r) { return r.begin(); } namespace { struct R { int* begin(); }; } static_assert(__is_same(decltype(begin(R())), int*)); int main() {} Even though ::begin is only used in an unevaluated context, GCC at -O0 generates code for begin, leading to a warning and a failure to link (https://gcc.godbolt.org/z/cdajoP7f3): :10:14: warning: 'int* {anonymous}::R::begin()' used but never defi= ned 10 | int* begin(); | ^~~~~ /opt/compiler-explorer/gcc-trunk-20230320/bin/../lib/gcc/x86_64-linux-gnu/1= 3.0.1/../../../../x86_64-linux-gnu/bin/ld: /tmp/cc7gqEhh.o: in function `auto begin<(anonymous namespace)::R&>((anonym= ous namespace)::R&)': :2: undefined reference to `(anonymous namespace)::R::begin()' collect2: error: ld returned 1 exit status Execution build compiler returned: 1=