public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide
@ 2021-04-13 12:56 andrey.davydov at jetbrains dot com
  2021-04-13 13:46 ` [Bug c++/100065] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: andrey.davydov at jetbrains dot com @ 2021-04-13 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100065
           Summary: Conditional explicit doesn't work for deduction guide
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrey.davydov at jetbrains dot com
  Target Milestone: ---

#include <type_traits>

template<bool b>
struct X
{
    template<typename T>
    X(T);
};

template<bool b>
explicit(b) X(std::bool_constant<b>) -> X<b>;

X false_ = std::false_type{}; // #1 should be OK
X true_  = std::true_type{};  // #2 should fail, but GCC compiles it

Note that other compilers (Clang, MSVC) rejects case #2:
https://gcc.godbolt.org/z/fPEKn1no9

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
@ 2021-04-13 13:46 ` redi at gcc dot gnu.org
  2021-04-13 14:11 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-13 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-04-13
     Ever confirmed|0                           |1

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
  2021-04-13 13:46 ` [Bug c++/100065] " redi at gcc dot gnu.org
@ 2021-04-13 14:11 ` mpolacek at gcc dot gnu.org
  2021-06-08 22:30 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-13 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
What would be mine (but most likely a GCC 12 thing).

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
  2021-04-13 13:46 ` [Bug c++/100065] " redi at gcc dot gnu.org
  2021-04-13 14:11 ` mpolacek at gcc dot gnu.org
@ 2021-06-08 22:30 ` cvs-commit at gcc dot gnu.org
  2021-06-08 22:30 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-08 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:1afa4facb9348cac0349ff9c30066aa25a3608f7

commit r12-1310-g1afa4facb9348cac0349ff9c30066aa25a3608f7
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jun 7 16:06:00 2021 -0400

    c++: explicit() ignored on deduction guide [PR100065]

    When we have explicit() with a value-dependent argument, we can't
    evaluate it at parsing time, so cp_parser_function_specifier_opt stashes
    the argument into the decl-specifiers and grokdeclarator then stores it
    into explicit_specifier_map, which is then used when substituting the
    function decl.  grokdeclarator stores it for constructors and conversion
    functions, but we also need to do it for deduction guides, otherwise
    we'll forget that we've seen an explicit-specifier as in the attached
    test.

            PR c++/100065

    gcc/cp/ChangeLog:

            * decl.c (grokdeclarator): Store a value-dependent
            explicit-specifier even for deduction guides.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/explicit18.C: New test.

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
                   ` (2 preceding siblings ...)
  2021-06-08 22:30 ` cvs-commit at gcc dot gnu.org
@ 2021-06-08 22:30 ` mpolacek at gcc dot gnu.org
  2021-06-09 14:07 ` cvs-commit at gcc dot gnu.org
  2021-06-09 14:13 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-08 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far, will backport.

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
                   ` (3 preceding siblings ...)
  2021-06-08 22:30 ` mpolacek at gcc dot gnu.org
@ 2021-06-09 14:07 ` cvs-commit at gcc dot gnu.org
  2021-06-09 14:13 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-09 14:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:0a9d8fd580d6afab669bae68e116e2135c2a8670

commit r11-8534-g0a9d8fd580d6afab669bae68e116e2135c2a8670
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jun 7 16:06:00 2021 -0400

    c++: explicit() ignored on deduction guide [PR100065]

    When we have explicit() with a value-dependent argument, we can't
    evaluate it at parsing time, so cp_parser_function_specifier_opt stashes
    the argument into the decl-specifiers and grokdeclarator then stores it
    into explicit_specifier_map, which is then used when substituting the
    function decl.  grokdeclarator stores it for constructors and conversion
    functions, but we also need to do it for deduction guides, otherwise
    we'll forget that we've seen an explicit-specifier as in the attached
    test.

            PR c++/100065

    gcc/cp/ChangeLog:

            * decl.c (grokdeclarator): Store a value-dependent
            explicit-specifier even for deduction guides.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/explicit18.C: New test.

    (cherry picked from commit 1afa4facb9348cac0349ff9c30066aa25a3608f7)

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

* [Bug c++/100065] Conditional explicit doesn't work for deduction guide
  2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
                   ` (4 preceding siblings ...)
  2021-06-09 14:07 ` cvs-commit at gcc dot gnu.org
@ 2021-06-09 14:13 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-06-09 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 12:56 [Bug c++/100065] New: Conditional explicit doesn't work for deduction guide andrey.davydov at jetbrains dot com
2021-04-13 13:46 ` [Bug c++/100065] " redi at gcc dot gnu.org
2021-04-13 14:11 ` mpolacek at gcc dot gnu.org
2021-06-08 22:30 ` cvs-commit at gcc dot gnu.org
2021-06-08 22:30 ` mpolacek at gcc dot gnu.org
2021-06-09 14:07 ` cvs-commit at gcc dot gnu.org
2021-06-09 14:13 ` mpolacek 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).