public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dodji at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55663] [C++11] Alias template combined with constexpr function is considered non-const Date: Tue, 15 Jan 2013 09:13:00 -0000 [thread overview] Message-ID: <bug-55663-4-t4Ua4Oo9pg@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55663-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55663 --- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2013-01-15 09:12:42 UTC --- Author: dodji Date: Tue Jan 15 09:12:30 2013 New Revision: 195189 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195189 Log: PR c++/55663 - constexpr function templ instantiation Consider the example of the problem report 1 template <typename> 2 constexpr bool the_truth () { return true; } 3 4 template <bool> 5 struct Takes_bool { }; 6 7 template<bool B> 8 using Alias = Takes_bool<B>; 9 10 template<typename T> 11 struct test { using type = Alias<the_truth<T>()>; }; 12 13 int main () { 14 test<int> a; 15 16 return 0; 17 } that yields the error: test.cc: In substitution of ‘template<bool B> using Alias = Takes_bool<B> [with bool B = the_truth<int>()]’: test.cc:11:51: required from ‘struct test<int>’ test.cc:14:13: required from here test.cc:11:51: error: integral expression ‘the_truth<int>()’ is not constant struct test { using type = Alias<the_truth<T>()>; }; I think the issue happens in the course of instantiating test<int> at line 14, when we look into instantiating Alias<the_truth<T>()> (at line 11) (using instantiate_alias_template) with T = int. There, when we check the argument 'the_truth<int>()' to see if it actually is a constant expression, in check_instantiated_arg, we fail to recognize it constexpr-ness b/c we just look at its TREE_CONSTANT. At that point, the_truth<int> should have been folded, and it's not, because instantiate_alias_template forgets to call coerce_template_parms on its arguments. Fixed thus, bootstapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ PR c++/55663 * pt.c (coerce_innermost_template_parms): New static function. (instantiate_alias_template): Use it here. gcc/testsuite/ PR c++/55663 * g++.dg/cpp0x/alias-decl-31.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-31.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
next prev parent reply other threads:[~2013-01-15 9:13 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-12 13:37 [Bug c++/55663] New: " daniel.kruegler at googlemail dot com 2012-12-14 21:36 ` [Bug c++/55663] " mlopez at cse dot tamu.edu 2012-12-14 22:08 ` redi at gcc dot gnu.org 2012-12-21 9:48 ` paolo.carlini at oracle dot com 2012-12-22 22:01 ` dodji at gcc dot gnu.org 2012-12-23 17:18 ` dodji at gcc dot gnu.org 2013-01-15 9:13 ` dodji at gcc dot gnu.org [this message] 2013-01-15 11:28 ` dodji at gcc dot gnu.org 2013-01-16 20:23 ` jason at gcc dot gnu.org 2013-01-21 13:33 ` paolo.carlini at oracle dot com
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-55663-4-t4Ua4Oo9pg@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: linkBe 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).