public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64356] New: Some constexpr expressions not recognized as constexpr
@ 2014-12-19  5:55 sneves at dei dot uc.pt
  2015-01-12 16:24 ` [Bug c++/64356] " ville.voutilainen at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sneves at dei dot uc.pt @ 2014-12-19  5:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64356
           Summary: Some constexpr expressions not recognized as constexpr
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sneves at dei dot uc.pt

Consider the following snippet:

  template<size_t N>
  constexpr uint64_t f(const char (&x)[N]) {
    uint64_t s = 0;
  #if defined(FAILS)
    for(uint64_t c : x)
      s += c;
  #else
    for(size_t i = 0; i < N; ++i)
      s += x[i];
  #endif
    return s;
  }

  template<size_t N>
  constexpr uint64_t g(const char (&x)[N]) {
    char y[N] = {0};
    for(size_t i = 0; i < N; ++i)
      y[i] = x[i];
  #if defined(FAILS)
    return f(y);
  #else
    return f(x);
  #endif
  }

  constexpr auto x = g(__DATE__);

When FAILS is defined, GCC (trunk, 20141219) refuses to recognize x as a
constant expression, while with FAILS undefined it works as expected. Clang
accepts both variants.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-15 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19  5:55 [Bug c++/64356] New: Some constexpr expressions not recognized as constexpr sneves at dei dot uc.pt
2015-01-12 16:24 ` [Bug c++/64356] " ville.voutilainen at gmail dot com
2015-01-13 14:45 ` jason at gcc dot gnu.org
2015-01-13 21:05 ` jason at gcc dot gnu.org
2015-01-15 20:46 ` jason at gcc dot gnu.org

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).