public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105761] New: ICE on hidden friend definition defined in base type
@ 2022-05-28 16:56 johelegp at gmail dot com
  2022-05-28 18:15 ` [Bug c++/105761] " johelegp at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: johelegp at gmail dot com @ 2022-05-28 16:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105761
           Summary: ICE on hidden friend definition defined in base type
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/v8arThEs1.

```C++
#include <type_traits>

template<class T> class X {
  friend auto f(X);
};

template<class T, class = std::void_t<>> struct downcast_t { using type = void;
};
template<class T> struct downcast_t<T, std::void_t<decltype(f(X<T>{}))>> {
using type = decltype(f(X<T>{})); };

template<class T> using downcast = typename downcast_t<T>::type;

static_assert(std::is_same_v<void, downcast<int>>);

struct Y : X<long> {
  friend auto f(X) { return 0L; }
};

static_assert(std::is_same_v<long, downcast<long>>);
```

```
<source>:4:18: warning: friend declaration 'auto f(X<T>)' declares a
non-template function [-Wnon-template-friend]
    4 |   friend auto f(X);
      |                  ^
<source>:4:18: note: (if this is not what you intended, make sure the function
template has already been declared and add '<>' after the function name here)
<source>:15:20: internal compiler error: in push_template_decl, at
cp/pt.cc:6125
   15 |   friend auto f(X) { return 0L; }
      |                    ^
0x21ffa39 internal_error(char const*, ...)
  ???:0
0x7452f3 fancy_abort(char const*, int, char const*)
  ???:0
0x82a0cd start_preparsed_function(tree_node*, tree_node*, int)
  ???:0
0x98cb8d c_parse_file()
  ???:0
0xb21d91 c_common_parse_file()
  ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

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

end of thread, other threads:[~2022-06-08 21:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 16:56 [Bug c++/105761] New: ICE on hidden friend definition defined in base type johelegp at gmail dot com
2022-05-28 18:15 ` [Bug c++/105761] " johelegp at gmail dot com
2022-05-30 10:04 ` [Bug c++/105761] [11/12/13 Regression] ICE on hidden friend definition defined in base type since r11-388-gc4bff4c230c8d341 marxin at gcc dot gnu.org
2022-06-03 16:27 ` jason at gcc dot gnu.org
2022-06-03 17:44 ` cvs-commit at gcc dot gnu.org
2022-06-03 18:12 ` cvs-commit at gcc dot gnu.org
2022-06-03 18:42 ` cvs-commit at gcc dot gnu.org
2022-06-03 18:43 ` jason at gcc dot gnu.org
2022-06-08 20:38 ` cvs-commit at gcc dot gnu.org
2022-06-08 21:31 ` cvs-commit at gcc dot gnu.org
2022-06-08 21:31 ` cvs-commit 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).