public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "faisalv at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49988] New: constexpr on ctor invokes improper initialization Date: Fri, 05 Aug 2011 12:27:00 -0000 [thread overview] Message-ID: <bug-49988-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49988 Summary: constexpr on ctor invokes improper initialization Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: faisalv@yahoo.com CC: jason@gcc.gnu.org The following code compiles fine, but displays incorrect (or at the very least inconsistent) behavior if constexpr is applied to A's ctor: template<int ... I> struct X { }; struct A { char data[3]; template<int ... I> constexpr // works if you comment this constexpr out A(const char (&s)[3], X<I...> x) : data{ s[I]...} { } // above also works if you leave constexpr in but replace // const char (&s)[3] with const char* s. }; struct B { A a; B(const char (&s)[3]) : a{s,X<0,1,2>{}} { } }; int main() { B b{"12"}; assert(b.a.data[0] == '1'); // assertion fails at run time } Compiled with gcc4.6.1 with *JUST* the following recent patch MANUALLY applied: http://gcc.gnu.org/viewcvs/branches/gcc-4_6-branch/gcc/cp/semantics.c?r1=177188&r2=177187&pathrev=177188 (please refer to PR c++/49924 for details) i.e gcc -v still reads (compared to PR c++/49924): Using built-in specs. COLLECT_GCC=g++-4.6.1 COLLECT_LTO_WRAPPER=/usr/local/gcc4.6.1/libexec/gcc/i686-pc-linux-gnu/4.6.1/lto-wrapper Target: i686-pc-linux-gnu Configured with: ../gcc-4.6.1/configure --prefix=/usr/local/gcc4.6.1 --enable-generated-files-in-srcdir --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-checking --disable-nls --enable-bootstrap --with-gcc --with-gnu-as --with-gnu-ld --disable-multilib Thread model: posix gcc version 4.6.1 (GCC) I wonder if just applying that one patch manually, while fixing one bug, could have introduced another? Thanks
next reply other threads:[~2011-08-05 12:27 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-08-05 12:27 faisalv at yahoo dot com [this message] 2011-08-05 14:00 ` [Bug c++/49988] " faisalv at yahoo dot com 2011-08-05 19:54 ` jason at gcc dot gnu.org 2011-08-06 4:34 ` jason at gcc dot gnu.org 2011-08-06 4:39 ` jason at gcc dot gnu.org 2011-08-06 22:25 ` 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-49988-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: 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).