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++/94511] User-defined type in non-type template parameter yields an incorrect value Date: Mon, 23 Aug 2021 20:58:47 +0000 [thread overview] Message-ID: <bug-94511-4-vKwFKEp4si@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94511-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94511 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2020-04-07 00:00:00 |2021-8-23 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note the cleaned up reduced testcase is rejected by clang but a slight change can allow it to be accepted: Change the using Bn line to be: using Bn = B< A{'\x0a'} >; I don't know if it was valid without the A there or not. Also here is a further reduction, the operators don't make a difference. Also this is a more portable testcase which also shows what is going on easier. #define element 0 #define value 1 #define altelement (element+1) #define r (value)|((element)<<4) #define r1 (value)|((altelement)<<4) struct A { unsigned data [16] {}; constexpr A (unsigned ch) { data[(ch>>4)&0xf] = (ch&0xf); } }; template <A chars> struct B { }; void check (A a) { for (int i = 0; i < 16; i++) if ((unsigned) a.data[i] != (i == element ? value : 0)) __builtin_abort (); } using Bn = B<A{r1}>; template <A T> void foo () { check (T); } int main () { foo<r> (); check (A{r}); }
prev parent reply other threads:[~2021-08-23 20:58 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-07 9:00 [Bug c++/94511] New: " pacoarjonilla at yahoo dot es 2020-04-07 9:41 ` [Bug c++/94511] " jakub at gcc dot gnu.org 2020-04-07 9:45 ` jakub at gcc dot gnu.org 2020-04-07 9:51 ` jakub at gcc dot gnu.org 2021-08-23 20:58 ` pinskia at gcc dot gnu.org [this message]
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-94511-4-vKwFKEp4si@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).