public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "trippels at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67104] [5/6 regression] Constant expression factory function initializes std::array with static storage duration strangely
Date: Fri, 07 Aug 2015 13:54:00 -0000	[thread overview]
Message-ID: <bug-67104-4-GF4lYKqsOP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67104-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67104

--- Comment #6 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Another example
http://stackoverflow.com/questions/31878796/removing-constexpr-changes-values-of-array-on-gcc

markus@x4 tmp % cat test.ii
template <typename T, int N> struct array
{
  constexpr T &operator[](int index) { return data[index]; }
  constexpr T operator[](int index) const { return data[index]; }
  T data[N];
};

constexpr array<long unsigned, 1001>
make_bottle_count ()
{
  array<long unsigned, 1001> a{};
  a[65] = 1;
  return a;
}

constexpr auto bottle_count = make_bottle_count ();
static_assert (bottle_count[65], "");

markus@x4 tmp % clang++ -c -std=c++14 test.ii
markus@x4 tmp % g++ -c -std=c++14 test.ii
test.ii:17:1: error: static assertion failed: 
 static_assert (bottle_count[65], "");
 ^


  parent reply	other threads:[~2015-08-07 13:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 17:48 [Bug c++/67104] New: " moritz at klammler dot eu
2015-08-03 17:49 ` [Bug c++/67104] " moritz at klammler dot eu
2015-08-03 17:50 ` moritz at klammler dot eu
2015-08-03 17:59 ` moritz at klammler dot eu
2015-08-03 18:29 ` trippels at gcc dot gnu.org
2015-08-04  8:40 ` [Bug c++/67104] [5/6 regression] " trippels at gcc dot gnu.org
2015-08-07 13:54 ` trippels at gcc dot gnu.org [this message]
2015-08-12 18:03 ` jason at gcc dot gnu.org
2015-08-12 18:09 ` jason at gcc dot gnu.org
2015-08-13  7:20 ` trippels at gcc dot gnu.org
2015-08-13  7:32 ` [Bug c++/67104] [5 " trippels at gcc dot gnu.org
2015-08-17 15:45 ` jason at gcc dot gnu.org
2015-08-17 16:06 ` jason at gcc dot gnu.org
2015-08-17 18:42 ` 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-67104-4-GF4lYKqsOP@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: link
Be 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).