From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 88983386EC6D for ; Mon, 20 Apr 2020 10:04:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 88983386EC6D Received: by mail-wm1-x331.google.com with SMTP id r26so10673474wmh.0 for ; Mon, 20 Apr 2020 03:04:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=rx7hZ2cfl9q/ymXWHcjzYTWZI2XOJdhDzbd5yHSp6U4=; b=pQ31QiiPwHHPsJXW83eI3lHx11MyyAHr5AdGC2xbhZKqRSlSXOqbnvwBBWIci7ygsX wq1iBohEVFzeihapE0VQBxlbO175I5FnewGqO0dnHwbOx6cd65fOiculm655yHO3POiV z9kqUdPLeUaizoyDGrPUa6diYTwNTVBCe4BaLATAE0PqkZk9f2JEnvTuv6dou9JkCtyI IRenDAybQOP+3nIvAQgnRkHj3ByrDZRcip+phoTDMhEdudbApLSWCglvtMFhpAv/58Gk DpVH+TpUu744kFXmqwT+uEwOUg4drZO7M6LatyKSv9lySxBxjB7PfjMVrvEHZvQQuXp6 gGnQ== X-Gm-Message-State: AGi0PuZFd9Yp5KRvo/MfMD+mGbjZTPsYUOHHkLkNYVI66jwGBw2pPGUy HXYmDO4lPeLTDEPF//DOG4bFJCjD4axtae194yB1XX01Ff0= X-Google-Smtp-Source: APiQypLYrAolDMfGrEfEg8rnNxlRe6ZCvYUkVDU0vMBhzYQtYF9mKntK6Wiuxg2N/21W7cy7QpYkHK6CZ5afi5zQTf8= X-Received: by 2002:a05:600c:28e:: with SMTP id 14mr7268975wmk.79.1587377047640; Mon, 20 Apr 2020 03:04:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bence Kodaj Date: Mon, 20 Apr 2020 12:03:56 +0200 Message-ID: Subject: Re: GCC 9.2, partial specialization with non-type template parameters: bug or not? To: gcc-help@gcc.gnu.org X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_2, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2020 10:04:11 -0000 Hi again, After running my code through GCC 9.3 on godbolt, I can now answer my own question :) Turns out this was indeed a bug in GCC 9.2, and it's fixed in GCC 9.3. Best regards, Bence Kodaj On Sat, Apr 18, 2020 at 9:51 PM Bence Kodaj wrote: > Dear list members, > > I'd like to ask for your help with the following: in GCC 9.2., is partial > template specialization expected to work for *all* allowed non-type > template parameters of class type? > > For a concrete example, please see the code below: it prints "false, > true", i.e., apparently, specializing T for X< Int > does not succeed, > whereas it does for Y< int >. Since Int is now (in C++20) allowed to be > used as the type of non-type template parameters, one would naively expect > the specialization of T for X< Int > to succeed just like the one for Y< > int > does. Is this belief justified, or am I missing something? > > Disclaimer: I do realize that C++20 support in GCC 9 is experimental - I'm > just looking for clarity regarding this issue, i.e., does the C++20 (draft) > standard require that the code below print "true, true"? > > Best regards, > Bence Kodaj > ------------- > - Compiler version (from g++ -v): gcc version 9.2.1 20191102 (Ubuntu > 9.2.1-17ubuntu1~18.04.1) > - Compilation command: g++ -std=c++2a main.cpp > > - Code: > #include > #include > > struct Int { > constexpr Int(int v): value{ v } {} > const int value; > }; > > template< Int i > > struct X {}; > > template< int i > > struct Y {}; > > template< typename > > struct T : std::false_type {}; > > template< Int i > > struct T< X< i > > : std::true_type {}; > > template< int i > > struct T< Y< i > > : std::true_type {}; > > int main() > { > std::cout << std::boolalpha << T< X< 123 > >::value << ", " << T< Y< > 123 > >::value << "\n"; > return 0; > } >