public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109232] New: Using deduced return type in an unevaluated context leads to codegen
@ 2023-03-21 13:15 rs2740 at gmail dot com
  2023-03-21 13:26 ` [Bug c++/109232] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rs2740 at gmail dot com @ 2023-03-21 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

            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<R>, leading to a warning and a failure to link
(https://gcc.godbolt.org/z/cdajoP7f3):

<source>:10:14: warning: 'int* {anonymous}::R::begin()' used but never defined
   10 |         int* begin();
      |              ^~~~~
/opt/compiler-explorer/gcc-trunk-20230320/bin/../lib/gcc/x86_64-linux-gnu/13.0.1/../../../../x86_64-linux-gnu/bin/ld:
/tmp/cc7gqEhh.o: in function `auto begin<(anonymous namespace)::R&>((anonymous
namespace)::R&)':
<source>:2: undefined reference to `(anonymous namespace)::R::begin()'
collect2: error: ld returned 1 exit status
Execution build compiler returned: 1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-22 14:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 13:15 [Bug c++/109232] New: Using deduced return type in an unevaluated context leads to codegen rs2740 at gmail dot com
2023-03-21 13:26 ` [Bug c++/109232] " rguenth at gcc dot gnu.org
2023-03-21 14:39 ` pinskia at gcc dot gnu.org
2023-03-22 14:13 ` ppalka at gcc dot gnu.org
2023-03-22 14:16 ` ppalka at gcc dot gnu.org
2023-03-22 14:21 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).