public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65327] New: GCC rejects "constexpr volatile int i = 5;"
@ 2015-03-05 17:44 Casey at Carter dot net
  2015-03-05 18:49 ` [Bug c++/65327] " yaghmour.shafik at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Casey at Carter dot net @ 2015-03-05 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65327
           Summary: GCC rejects "constexpr volatile int i = 5;"
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Casey at Carter dot net

See
http://stackoverflow.com/questions/28883510/can-constexpr-be-combined-with-volatile
for discussion. GCC 5 (Identified as "5.0.0 HEAD 20150304" on Wandbox at
http://melpon.org/wandbox/permlink/u7BC3wFEfMv0zrVN) rejects this program:

int main() {
    constexpr volatile int i = 5;
}

with the diagnostic:

prog.cc: In function 'int main()':
prog.cc:3:28: error: both 'volatile' and 'constexpr' cannot be used here
    constexpr volatile int i = 5;

AFAICT, this program is well-formed: `constexpr` can be applied to literal
types, which includes scalar types, which includes cv-qualified arithmetic
types. Semantically, I *think* "constexpr volatile" is equivalent to "const
volatile" since "constexpr" objects are implicitly "const" but lvalue-to-rvalue
conversions applied to volatile glvalues cannot be part of a
core-constant-expression.


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

end of thread, other threads:[~2015-03-16 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 17:44 [Bug c++/65327] New: GCC rejects "constexpr volatile int i = 5;" Casey at Carter dot net
2015-03-05 18:49 ` [Bug c++/65327] " yaghmour.shafik at gmail dot com
2015-03-16  9:42 ` mpolacek at gcc dot gnu.org
2015-03-16  9:56 ` mpolacek at gcc dot gnu.org
2015-03-16 10:29 ` mpolacek at gcc dot gnu.org
2015-03-16 18:31 ` mpolacek at gcc dot gnu.org
2015-03-16 18:32 ` mpolacek 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).