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

* [Bug c++/100592] Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template
  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 ` marxin at gcc dot gnu.org
  2021-06-02 16:16 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-05-14

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, clang accepts that.

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

* [Bug c++/100592] Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template
  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
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-02 16:16 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

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

* [Bug c++/100592] Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template
  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
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-03 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:d999d9b7e53b9a9cd2004a19e84c637e5e5013f5

commit r12-1183-gd999d9b7e53b9a9cd2004a19e84c637e5e5013f5
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 3 09:39:13 2021 -0400

    c++: cv-qualified dependent name of alias tmpl [PR100592]

    Here, the dependent template name in the return type of f() resolves to
    an alias of int& after substitution, and we end up complaining about
    qualifying this reference type with 'const' from cp_build_qualified_type
    rather than just silently dropping the qualification as per [dcl.ref]/1.

    The problem is ultimately that make_typename_type ignores the
    tf_keep_type_decl flag when the dependent name is a template-id.  This
    in turn causes the TYPE_DECL check within tsubst <case TYPENAME_TYPE>
    to fail, and so we end up not passing tf_ignore_bad_quals to
    cp_build_qualified_type.  This patch fixes this by making
    make_typename_type respect the tf_keep_type_decl flag in this situation.

            PR c++/100592

    gcc/cp/ChangeLog:

            * decl.c (make_typename_type): After calling
            lookup_template_class, adjust the result to its TYPE_NAME and
            then consider the tf_keep_type_decl flag.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-71.C: New test.

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

* [Bug c++/100592] Bogus "qualifiers cannot be applied" error with reference type produced by dependent alias template
  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
                   ` (2 preceding siblings ...)
  2021-06-03 13:39 ` cvs-commit at gcc dot gnu.org
@ 2021-11-07  0:27 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-11-07  0:27 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |12.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

^ 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).