public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60955] Erroneous warning about taking address of register with std=c++1y
Date: Sat, 26 Apr 2014 16:40:00 -0000	[thread overview]
Message-ID: <bug-60955-4-okbrR04LNa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60955-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60955

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-26
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Harald van Dijk from comment #2)
> This is caused by the implementation of C++1y decltype(auto), where
> seemingly redundant parentheses around an identifier must not simply be
> removed, because they may be significant.
> 
> int a;
> decltype(auto) b = a; // means int b = a;
> decltype(auto) c = (a); // means int &c = a;
> 
> GCC implements this by transforming (a) into static_cast<int &>(a)
> (force_paren_expr in gcc/cp/semantics.c), which would normally be a no-op,
> but causes the warning when a is declared using the "register" keyword.

It is pretty awful that C++14 has made extra parentheses to become significant.

But yes, this explains this bug and also PR57573.

It would be nice if expressions could be marked as compiler-generated, like we
have DECL_ARTIFICIAL for declarations. But you could set TREE_NO_WARNING(expr)
= true and check that in the warning code.
>From gcc-bugs-return-449970-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Apr 26 16:42:33 2014
Return-Path: <gcc-bugs-return-449970-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12785 invoked by alias); 26 Apr 2014 16:42:32 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12739 invoked by uid 48); 26 Apr 2014 16:42:29 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60955] Erroneous warning about taking address of register with std=c++1y
Date: Sat, 26 Apr 2014 16:42:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60955-4-A1SMs9nnPq@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60955-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60955-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01990.txt.bz2
Content-length: 850

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60955

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Perhaps also this special case could also be removed by using TREE_NO_WARNING.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c91612c..d8374d9 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6291,7 +6291,10 @@ maybe_warn_about_useless_cast (tree type, tree expr,
tsubst_flags_t complain)
   if (warn_useless_cast
       && complain & tf_warning)
     {
-      if (REFERENCE_REF_P (expr))
+      /* In C++14 mode, this interacts badly with force_paren_expr.  And it
+     isn't necessary in any mode, because the code below handles
+     glvalues properly.  For 4.9, just skip it in C++14 mode.  */
+      if (cxx_dialect < cxx1y && REFERENCE_REF_P (expr))
     expr = TREE_OPERAND (expr, 0);
>From gcc-bugs-return-449971-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Apr 26 21:53:06 2014
Return-Path: <gcc-bugs-return-449971-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2134 invoked by alias); 26 Apr 2014 21:53:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 2092 invoked by uid 55); 26 Apr 2014 21:53:01 -0000
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/52539] I/O: Wrong result for UTF-8/UCS-4 list-directed and namelist read and nml write
Date: Sat, 26 Apr 2014 21:53:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libfortran
X-Bugzilla-Version: 4.8.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jvdelisle at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: jvdelisle at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-52539-4-CsRiqkIpS2@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-52539-4@http.gcc.gnu.org/bugzilla/>
References: <bug-52539-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01991.txt.bz2
Content-length: 953

http://gcc.gnu.org/bugzilla/show_bug.cgi?idR539

--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Author: jvdelisle
Date: Sat Apr 26 21:52:26 2014
New Revision: 209828

URL: http://gcc.gnu.org/viewcvs?rev 9828&root=gcc&view=rev
Log:
2014-04-26  Jerry DeLisle  <jvdelisle@gcc.gnu>

    PR libfortran/52539
    * io/list_read.c: Add uchar typedef. (push_char4): New function
    to save kind=4 character. (next_char_utf8): New function to read
    a single UTF-8 encoded character value. (read_chracter): Update
    to use the new functions for reading UTF-8 strings.
    (list_formatted_read_scalar): Update to handle list directed
    reads of UTF-8 strings. (nml_read_obj): Likewise update for
    UTF-8 strings in namelists.
    * io/write.c (nml_write_obj): Add kind=4 character support for
    namelist writes.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/write.c


  parent reply	other threads:[~2014-04-26 16:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 19:09 [Bug c++/60955] New: " matt at godbolt dot org
2014-04-26 15:45 ` [Bug c++/60955] " harald at gigawatt dot nl
2014-04-26 16:40 ` manu at gcc dot gnu.org [this message]
2014-12-05 11:55 ` [Bug c++/60955] [4.9/5 Regression] " paolo.carlini at oracle dot com
2014-12-05 12:17 ` manu at gcc dot gnu.org
2014-12-10 16:24 ` paolo.carlini at oracle dot com
2014-12-10 18:09 ` paolo.carlini at oracle dot com
2014-12-18 17:54 ` paolo at gcc dot gnu.org
2014-12-19  9:13 ` paolo at gcc dot gnu.org
2014-12-19  9:25 ` paolo.carlini at oracle 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-60955-4-okbrR04LNa@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).