public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
@ 2020-05-18  9:24 ` suratovvlad at gmail dot com
  2021-08-28  2:44 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: suratovvlad at gmail dot com @ 2020-05-18  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Vladislav Suratov <suratovvlad at gmail dot com> ---
Confirmed with 9.3, 10.1 and current trunk (11.0). 
Tested with --std=c++17, meanwhile clang 10.0 (and trunk) and MSVC 19.24 and
MSVC 19.25 successfully compile it.
The following example is what I used for testing:

#include <ratio>

struct Test1
{
    template <typename _Ty>
    struct Helper1{
      static constexpr bool value = false;
    };

    template <intmax_t _R1, intmax_t _R2>
    struct Helper1<std::ratio<_R1, _R2>>{
      static constexpr bool value = true;
    };
};

struct Test2
{
    template <typename _Ty>
    static constexpr bool Helper1 = false;

    template <intmax_t _R1, intmax_t _R2>
    static constexpr bool Helper1<std::ratio<_R1, _R2>> = true;
};

static_assert(Test1::Helper1<std::ratio<1, 1000>>::value, "Check");
static_assert(Test2::Helper1<std::ratio<1, 1000>>, "Check");

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
  2020-05-18  9:24 ` [Bug c++/71954] template partial specialization for constexpr error suratovvlad at gmail dot com
@ 2021-08-28  2:44 ` pinskia at gcc dot gnu.org
  2021-08-28  2:45 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  2:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redbeard0531 at gmail dot com

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 90031 has been marked as a duplicate of this bug. ***

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
  2020-05-18  9:24 ` [Bug c++/71954] template partial specialization for constexpr error suratovvlad at gmail dot com
  2021-08-28  2:44 ` pinskia at gcc dot gnu.org
@ 2021-08-28  2:45 ` pinskia at gcc dot gnu.org
  2022-07-31  4:56 ` lichray at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase from the other bug:

struct Struct {
    template <typename T, typename = void>
    constexpr static bool use_cond = false;
    template <typename T>
    constexpr static bool use_cond<T, void> = true;
};

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-08-28  2:45 ` pinskia at gcc dot gnu.org
@ 2022-07-31  4:56 ` lichray at gmail dot com
  2022-07-31 20:08 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: lichray at gmail dot com @ 2022-07-31  4:56 UTC (permalink / raw)
  To: gcc-bugs

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

Zhihao Yuan <lichray at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lichray at gmail dot com

--- Comment #5 from Zhihao Yuan <lichray at gmail dot com> ---
Please fix. The workaround is to write

struct Struct {
    template <typename T, typename = void>
    constexpr static bool use_cond = false;
};

template <typename T>
constexpr bool Struct::use_cond<T, void> = true;

But when the enclosing context is a class template, writing such a partial
specialization will be very tedious.

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-07-31  4:56 ` lichray at gmail dot com
@ 2022-07-31 20:08 ` pinskia at gcc dot gnu.org
  2023-02-14 12:51 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-31 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlame646 at gmail dot com

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 106478 has been marked as a duplicate of this bug. ***

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-07-31 20:08 ` pinskia at gcc dot gnu.org
@ 2023-02-14 12:51 ` redi at gcc dot gnu.org
  2023-08-11 17:26 ` cvs-commit at gcc dot gnu.org
  2023-08-11 17:30 ` ppalka at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-02-14 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=85282
   Last reconfirmed|2016-07-22 00:00:00         |2023-2-14

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I wonder if this can be fixed as part of PR 85282.

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-02-14 12:51 ` redi at gcc dot gnu.org
@ 2023-08-11 17:26 ` cvs-commit at gcc dot gnu.org
  2023-08-11 17:30 ` ppalka at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-11 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:ca2676654736e6b0bd1ba88edf5694df43718cd9

commit r14-3160-gca2676654736e6b0bd1ba88edf5694df43718cd9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Aug 11 13:25:58 2023 -0400

    c++: recognize in-class var tmpl partial spec [PR71954]

    This makes us recognize member variable template partial specializations
    defined directly inside the class body.  It seems we mainly just need to
    call check_explicit_specialization when we see a static TEMPLATE_ID_EXPR
    data member, which sets SET_DECL_TEMPLATE_SPECIALIZATION for us and which
    we otherwise don't call (for the out-of-class case we call it from
    grokvardecl).

    We also need to make finish_member_template_decl return NULL_TREE for
    such partial specializations, matching its behavior for class template
    partial specializations, so that later we don't try to register it as a
    separate member declaration.

            PR c++/71954

    gcc/cp/ChangeLog:

            * decl.cc (grokdeclarator): Pass 'dname' instead of
            'unqualified_id' as the name when building the VAR_DECL for a
            static data member.  Call check_explicit_specialization for a
            TEMPLATE_ID_EXPR such member.
            * pt.cc (finish_member_template_decl): Return NULL_TREE
            instead of 'decl' when DECL_TEMPLATE_SPECIALIZATION is not
            set.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/var-templ84.C: New test.
            * g++.dg/cpp1y/var-templ84a.C: New test.

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

* [Bug c++/71954] template partial specialization for constexpr error
       [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-08-11 17:26 ` cvs-commit at gcc dot gnu.org
@ 2023-08-11 17:30 ` ppalka at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-08-11 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|NEW                         |RESOLVED

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

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

end of thread, other threads:[~2023-08-11 17:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-71954-4@http.gcc.gnu.org/bugzilla/>
2020-05-18  9:24 ` [Bug c++/71954] template partial specialization for constexpr error suratovvlad at gmail dot com
2021-08-28  2:44 ` pinskia at gcc dot gnu.org
2021-08-28  2:45 ` pinskia at gcc dot gnu.org
2022-07-31  4:56 ` lichray at gmail dot com
2022-07-31 20:08 ` pinskia at gcc dot gnu.org
2023-02-14 12:51 ` redi at gcc dot gnu.org
2023-08-11 17:26 ` cvs-commit at gcc dot gnu.org
2023-08-11 17:30 ` 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).