public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112632] New: [14 Regression]  Non-type template parameter created with converting constructor sometimes has original type
Date: Mon, 20 Nov 2023 05:08:02 +0000	[thread overview]
Message-ID: <bug-112632-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112632
           Summary: [14 Regression]  Non-type template parameter created
                    with converting constructor sometimes has original
                    type
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: needs-bisection, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
    template<typename T>
    inline constexpr bool C = true;

    struct n {
        constexpr n(int a) : i(a) {}
        int i;
    };

    template<n N>
    using get_n_i_type = decltype(N.i);

    template<int X>
    int f() {
        using iii = get_n_i_type<X>;
    #if 1  // Change to 0 and this compiles
        static_assert(C<iii>);
    #endif
        return iii{};
    }

    template int f<3>();
```

This is rejected on the trunk with:
```
<source>: In instantiation of 'int f() [with int X = 3]':
<source>:22:23:   required from here
   22 |     template int f<3>();
      |                       ^
<source>:11:37: error: request for member 'i' in '3', which is of non-class
type 'int'
   11 |     using get_n_i_type = decltype(N.i);
      |                                   ~~^
```

But was accepted in GCC 13.  Note the difference between this and PR 112594 is
that C here is declared an `inline constexpr` rather than a concept.

             reply	other threads:[~2023-11-20  5:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  5:08 pinskia at gcc dot gnu.org [this message]
2023-11-20  5:08 ` [Bug c++/112632] " pinskia at gcc dot gnu.org
2023-11-20 14:32 ` ppalka at gcc dot gnu.org
2024-01-10 13:45 ` rguenth at gcc dot gnu.org
2024-01-17 22:07 ` jason at gcc dot gnu.org
2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
2024-01-19 18:37 ` jason 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-112632-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).