public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "miyuki at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67333] [C++11][constexpr] constexpr functions incorrectly prohibit taking references to volatile types
Date: Mon, 24 Aug 2015 05:50:00 -0000	[thread overview]
Message-ID: <bug-67333-4-NBBpej8gKb@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67333-4@http.gcc.gnu.org/bugzilla/>

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

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |miyuki at gcc dot gnu.org

--- Comment #1 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
EDG accepts the first testcase. The second one is rejected, but presumably due
to incomplete C++14 support.

In potential_constant_expression_1 we have a check:

  if (TREE_THIS_VOLATILE (t))
    {
      if (flags & tf_error)
        error ("expression %qE has side-effects", t);

The comment in tree.h says:
/* Nonzero means this expression is volatile in the C sense:
   its address should be of type `volatile WHATEVER *'.
   In other words, the declared item is volatile qualified.
...
   If this bit is set in an expression, so is TREE_SIDE_EFFECTS.  */

In our case t is:
(gdb) p t
$10 = <var_decl 0x7ffff66a7cf0 meow>
(gdb) pt
warning: Expression is not an assignment (and might have no effect)
 <var_decl 0x7ffff66a7cf0 meow
    type <array_type 0x7ffff6800c78
        type <integer_type 0x7ffff6800a80 int volatile type_6 SI
            size <integer_cst 0x7ffff66bd0a8 constant 32>
            unit size <integer_cst 0x7ffff66bd0c0 constant 4>
            align 32 symtab 0 alias set -1 canonical type 0x7ffff6800a80
precision 32 min <integer_cst 0x7ffff66bd060 -2147483648> max <integer_cst
0x7ffff66bd078 2147483647>
            pointer_to_this <pointer_type 0x7ffff6800d20>>
        TI
        size <integer_cst 0x7ffff669bea0 constant 128>
        unit size <integer_cst 0x7ffff669beb8 constant 16>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff6800c78
        domain <integer_type 0x7ffff6800b28 type <integer_type 0x7ffff669f1f8
sizetype>
            type_6 DI
            size <integer_cst 0x7ffff669be58 constant 64>
            unit size <integer_cst 0x7ffff669be70 constant 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff6800b28
precision 64 min <integer_cst 0x7ffff669be88 0> max <integer_cst 0x7ffff680adc8
3>>
        pointer_to_this <pointer_type 0x7ffff68133f0>>
    side-effects addressable volatile used tree_1 decl_5 TI file
/home/miyuki/gcc/test/meow/meow.cc line 15 col 18 size <integer_cst
0x7ffff669bea0 128> unit size <integer_cst 0x7ffff669beb8 16>
    align 32 context <function_decl 0x7ffff67ffe00 main>>

I.e. the condition is probably wrong and we should also check that t is an
expression, not a declaration.


  reply	other threads:[~2015-08-24  5:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24  4:39 [Bug c++/67333] New: " myriachan at gmail dot com
2015-08-24  5:50 ` miyuki at gcc dot gnu.org [this message]
2015-08-29 22:23 ` [Bug c++/67333] " miyuki 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-67333-4-NBBpej8gKb@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).