public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hokein.wu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114903] New: constraint of CTAD alias deduction guide is evaluated on a wrong type
Date: Wed, 01 May 2024 08:06:44 +0000	[thread overview]
Message-ID: <bug-114903-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114903
           Summary: constraint of CTAD alias deduction guide is evaluated
                    on a wrong type
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hokein.wu at gmail dot com
  Target Milestone: ---

See the following example of nested templates:  

```
#include <type_traits>
template <typename T>
struct Key {
  Key(int);
};

class Forward {};

template <typename T>
constexpr bool C =
    std::is_same<T, Forward>(); // changing `Forward` to `double` will make the
following static_assert passed.

template <typename Z>
struct Outer {
  template <typename U>
  struct Foo {
    Foo(U);
    U u;
  };

  template <typename V>
    requires(C<Z>)
  Foo(V) -> Foo<int>;
};

template <typename Y>
struct T {
  template <typename Y2>
  struct T2 {
    template <typename K>
    using AFoo = Outer<Y2>::template Foo<K>;
  };
};

T<Forward>::T2<Forward>::AFoo a{1.0};  // the explict deduction guide should be
choosen, Foo<int>
static_assert(std::is_same<decltype(a), Outer<Forward>::Foo<int>>()); // expect
to be true!
```

The constraint `C` in the alias deduction guide should be true, as it is
evaluated on type `Forward`, but gcc seems to evaluate it on `double`.

             reply	other threads:[~2024-05-01  8:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01  8:06 hokein.wu at gmail dot com [this message]
2024-05-13 13:53 ` [Bug c++/114903] " cvs-commit at gcc dot gnu.org
2024-05-13 15:39 ` cvs-commit at gcc dot gnu.org
2024-05-13 15:41 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114903-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).