public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100592] New: Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template
@ 2021-05-14  0:22 rs2740 at gmail dot com
  2021-05-14  7:19 ` [Bug c++/100592] " marxin at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rs2740 at gmail dot com @ 2021-05-14  0:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100592
           Summary: Bogus "qualifiers cannot be applied" error with
                    reference type produced by dependent alias template
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

template<bool>
struct meta {
    template<class T, class U>
    using if_c = T;
};

template<>
struct meta<false> {
    template<class T, class U>
    using if_c = U;
};

template <bool B, class T, class U>
using if_c = typename meta<B>::template if_c<T, U>;

template<class>
inline constexpr bool b = false;

template <class T>
using foo = if_c<b<T>, int, T>;

template<class T>
struct type {};

template <typename T>
using test = type<foo<T> const&>;

template<class T>
test<T> f();

void g() {
    f<int&>();
}

GCC rejects:

<source>: In function 'void g()':
<source>:32:12: error: no matching function for call to 'f<int&>()'
   32 |     f<int&>();
      |     ~~~~~~~^~
<source>:29:9: note: candidate: 'template<class T> test<T> f()'
   29 | test<T> f();
      |         ^
<source>:29:9: note:   template argument deduction/substitution failed:
<source>: In substitution of 'template<class T> using test = type<const
typename meta<b<T> >::if_c<int, T>&> [with T = int&]':
<source>:29:9:   required by substitution of 'template<class T> test<T> f()
[with T = int&]'
<source>:32:12:   required from here
<source>:26:7: error: 'const' qualifiers cannot be applied to
'meta<false>::if_c<int, int&>' {aka 'int&'}
   26 | using test = type<foo<T> const&>;
      |       ^~~~

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

end of thread, other threads:[~2021-11-07  0:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  0:22 [Bug c++/100592] New: Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template rs2740 at gmail dot com
2021-05-14  7:19 ` [Bug c++/100592] " marxin at gcc dot gnu.org
2021-06-02 16:16 ` ppalka at gcc dot gnu.org
2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
2021-11-07  0:27 ` 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).