Bug 98486 - Variable template specialization doesn't account for primary's constraints
Summary: Variable template specialization doesn't account for primary's constraints
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.3
Assignee: Patrick Palka
URL: https://godbolt.org/z/jon9ea
Keywords: accepts-invalid
Depends on:
Blocks: concepts
  Show dependency treegraph
 
Reported: 2020-12-31 06:57 UTC by Johel Ernesto Guerrero Peña
Modified: 2021-10-06 14:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-07-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johel Ernesto Guerrero Peña 2020-12-31 06:57:59 UTC
See https://godbolt.org/z/jon9ea.
```C++
template<class>concept C=false;
template<C>int v;
struct X{};
template<>X v<X>;
```
Comment 1 GCC Commits 2021-09-16 19:04:24 UTC
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:2e2e65a46d2674bed53afd211493876ee2b79453

commit r12-3585-g2e2e65a46d2674bed53afd211493876ee2b79453
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Sep 16 15:03:55 2021 -0400

    c++: constrained variable template issues [PR98486]
    
    This fixes some issues with constrained variable templates:
    
      - Constraints aren't checked when explicitly specializing a variable
        template.
      - Constraints aren't attached to a static data member template at
        parse time.
      - Constraints don't get propagated when (partially) instantiating a
        static data member template, so we need to make sure to look up
        constraints using the most general template during satisfaction.
    
            PR c++/98486
    
    gcc/cp/ChangeLog:
    
            * constraint.cc (get_normalized_constraints_from_decl): Always
            look up constraints using the most general template.
            * decl.c (grokdeclarator): Set constraints on a static data
            member template.
            * pt.c (determine_specialization): Check constraints on a
            variable template.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-var-templ1.C: New test.
            * g++.dg/cpp2a/concepts-var-templ1a.C: New test.
            * g++.dg/cpp2a/concepts-var-templ1b.C: New test.
Comment 2 GCC Commits 2021-10-06 14:15:30 UTC
The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:729cf2ea979f396e706625b1669087d5920b8c2a

commit r11-9081-g729cf2ea979f396e706625b1669087d5920b8c2a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Sep 16 15:03:55 2021 -0400

    c++: constrained variable template issues [PR98486]
    
    This fixes some issues with constrained variable templates:
    
      - Constraints aren't checked when explicitly specializing a variable
        template.
      - Constraints aren't attached to a static data member template at
        parse time.
      - Constraints don't get propagated when (partially) instantiating a
        static data member template, so we need to make sure to look up
        constraints using the most general template during satisfaction.
    
            PR c++/98486
    
    gcc/cp/ChangeLog:
    
            * constraint.cc (get_normalized_constraints_from_decl): Always
            look up constraints using the most general template.
            * decl.c (grokdeclarator): Set constraints on a static data
            member template.
            * pt.c (determine_specialization): Check constraints on a
            variable template.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-var-templ1.C: New test.
            * g++.dg/cpp2a/concepts-var-templ1a.C: New test.
            * g++.dg/cpp2a/concepts-var-templ1b.C: New test.
    
    (cherry picked from commit 2e2e65a46d2674bed53afd211493876ee2b79453)
Comment 3 Patrick Palka 2021-10-06 14:18:56 UTC
Fixed for GCC 11.3 and 12.