public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xskxzr at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99130] New: Variable template in unevaluated context is wrongly implicitly instantiated
Date: Wed, 17 Feb 2021 05:52:29 +0000	[thread overview]
Message-ID: <bug-99130-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 99130
           Summary: Variable template in unevaluated context is wrongly
                    implicitly instantiated
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xskxzr at gmail dot com
  Target Milestone: ---

Motivated by the StackOverflow post:
https://stackoverflow.com/questions/66214214/different-sfinae-behavior-of-stdtuple-size-v-on-different-compilers

The following code does not compile:


    #include <type_traits>
    #include <iostream>

    template<typename T> constexpr int f() { return T::value; }
    template<typename T> constexpr int z = T::value;
    template<typename T, typename = int> struct G : std::false_type {};
    template<typename T> struct G<T, decltype(z<T>)> : std::true_type {}; //
error
    // template<typename T> struct G<T, decltype(f<T>())> : std::true_type {};
// ok

    int main() {
      std::cout << G<int>::value; 
    }

Here the definition of z<T> is not required, so its definition shouldn't be
implicitly instantiated.

Note if we replace z<T> by f<T>(), the code compiles successfully.

             reply	other threads:[~2021-02-17  5:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17  5:52 xskxzr at gmail dot com [this message]
2021-08-17  9:37 ` [Bug c++/99130] " pinskia at gcc dot gnu.org
2021-08-17  9:51 ` [Bug c++/99130] variable template in unevaluated context is instantiated when should not be pinskia at gcc dot gnu.org
2021-08-17 10:02 ` pinskia at gcc dot gnu.org
2022-09-08 13:45 ` cvs-commit at gcc dot gnu.org
2022-09-08 13:48 ` 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-99130-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).