public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "akim.demaille at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51253] [C++11][DR 1030] Evaluation order (sequenced-before relation) among initializer-clauses in braced-init-list Date: Thu, 10 Apr 2014 08:14:00 -0000 [thread overview] Message-ID: <bug-51253-4-CTn4d0qAtw@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-51253-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253 --- Comment #10 from Akim Demaille <akim.demaille at gmail dot com> --- Well, I have finally found a simple workaround for some of the cases: GCC seems to be right in the order of evaluation when initializing an array so: template<int... IS> int f1() { int i = 0; swallow{ i = 10 * i + IS... }; return i; } fails, but template<int... IS> int f2() { using swallow = int[]; int i = 0; (void) swallow{ i = 10 * i + IS... }; return i; } succeeds. However, GCC's own libstdc++ is exposed to this bug, for instance make_tuple. $ cat foo.cc #include <iostream> #include <tuple> struct swallow { template<typename... Types> swallow(Types &&...){} }; int incr() { static int res = 2; return res++; } template<int... IS> int f1() { int i = 0; swallow{ i = 10 * i + IS... }; return i; } template<int... IS> int f2() { using swallow = int[]; int i = 0; (void) swallow{ i = 10 * i + IS... }; return i; } int main() { // `i = i * 2 + 2' should be sequenced before `i = i * 3 + 3' std::cerr << f1<2, 3>() << '\t'; std::cerr << f2<2, 3>() << '\t'; auto t = std::make_tuple(incr(), incr()); std::cerr << std::get<0>(t) << std::get<1>(t) << '\n'; } $ ./a.32 23 23 23 $ ./a.33 23 23 23 $ ./a.34 23 23 23 $ ./a.35 23 23 23 $ ./a.48 32 23 32 $ ./a.49 32 23 32 where 32...35 is clang++, and 48,49 is gcc.
next prev parent reply other threads:[~2014-04-10 8:14 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-11-21 4:24 [Bug c++/51253] New: [C++11][DR 1030] Evaluation order (sequenced-before relation) among intializer-clauses " ai.azuma at gmail dot com 2012-10-10 9:24 ` [Bug c++/51253] [C++11][DR 1030] Evaluation order (sequenced-before relation) among initializer-clauses " paolo.carlini at oracle dot com 2013-07-05 13:49 ` akim.demaille at gmail dot com 2013-07-05 15:06 ` paolo.carlini at oracle dot com 2013-08-13 17:07 ` broes.decat at gmail dot com 2013-10-23 16:38 ` st at quanttec dot com 2013-11-25 11:54 ` akim.demaille at gmail dot com 2014-01-18 16:12 ` akim.demaille at gmail dot com 2014-03-06 14:38 ` akim.demaille at gmail dot com 2014-03-13 17:07 ` paolo.carlini at oracle dot com 2014-03-13 17:40 ` manu at gcc dot gnu.org 2014-04-10 8:14 ` akim.demaille at gmail dot com [this message] 2014-04-11 17:09 ` jason at gcc dot gnu.org 2014-06-03 9:29 ` redi at gcc dot gnu.org 2014-06-04 1:11 ` redi at gcc dot gnu.org 2014-06-04 6:23 ` akim.demaille at gmail dot com 2014-06-04 15:51 ` jason at gcc dot gnu.org 2014-06-30 14:26 ` jason at gcc dot gnu.org 2014-07-01 8:20 ` christophe.lyon at st dot com 2014-07-03 2:11 ` jason at gcc dot gnu.org 2014-07-07 11:57 ` christophe.lyon at st dot com 2014-08-01 18:53 ` jason at gcc dot gnu.org 2014-08-06 18:36 ` dacamara.cameron at gmail 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-51253-4-CTn4d0qAtw@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).