public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60955] New: Erroneous warning about taking address of register with std=c++1y
@ 2014-04-24 19:09 matt at godbolt dot org
  2014-04-26 15:45 ` [Bug c++/60955] " harald at gigawatt dot nl
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: matt at godbolt dot org @ 2014-04-24 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60955
           Summary: Erroneous warning about taking address of register
                    with std=c++1y
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt at godbolt dot org

This short snippet, when compiled with GCC4.9.0 and -Wextra and -std=c++1y,
gives an erroneous warning about taking the address of a register:

===
$ cat test2.cc
// compile with -Wextra -std=c++1y
unsigned int erroneous_warning(register int a) {
    if ((a) & 0xff) return 1; else return 0;
}
unsigned int no_erroneous_warning(register int a) {
    if (a & 0xff) return 1; else return 0;
}
$ g++ -Wextra -std=c++11 -c test2.cc
test2.cc: In function ‘unsigned int erroneous_warning(int)’:
test2.cc:3:10: warning: address requested for ‘a’, which is declared ‘register’
[-Wextra]
     if ((a) & 0xff) return 1; else return 0;
          ^
$ g++ -v
Using built-in specs.
COLLECT_GCC=/home/mgodbolt/.fighome/runtime/gcc/4.9.0-2/bin/g++
COLLECT_LTO_WRAPPER=/mnt/data/fighome/runtime/gcc/4.9.0-2/bin/../libexec/gcc/x86_64-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-4.9.0/configure --prefix
/data/teamcity/work/sud-chibld05-002-RHEL6/9d49ff0b2777552a/scratch/gcc/4.9.0/staging
--build=x86_64-linux-gnu --disable-multilibs --enable-clocale=gnu
--enable-languages=c,c++ --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --with-pkgversion=DRW-internal-build
--with-system-zlib --disable-werror
--with-libelf=/data/teamcity/work/sud-chibld05-002-RHEL6/9d49ff0b2777552a/scratch/gcc/4.9.0/build/libelf-0.8.13
Thread model: posix
gcc version 4.9.0 (DRW-internal-build) 
===

When compiled with -std=c++11 the warning disappears.  Note the extra
parentheses are also needed to trigger the warning.
>From gcc-bugs-return-449821-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 24 19:36:32 2014
Return-Path: <gcc-bugs-return-449821-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 4416 invoked by alias); 24 Apr 2014 19:36:31 -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 4351 invoked by uid 48); 24 Apr 2014 19:36:25 -0000
From: "matt at godbolt dot 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: Thu, 24 Apr 2014 19:36: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: matt at godbolt dot org
X-Bugzilla-Status: UNCONFIRMED
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-M5P1q28rH3@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: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01841.txt.bz2
Content-length: 388

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`955

--- Comment #1 from Matt Godbolt <matt at godbolt dot org> ---
The previous snippet wasn't quite as minimal as it could be.  This single line
also reproduces it:

unsigned int erroneous_warning(register int a) { return (a); }

Jonathan Wakely mentioned this may be related to this bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?idW573


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

end of thread, other threads:[~2014-12-19  9:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 19:09 [Bug c++/60955] New: Erroneous warning about taking address of register with std=c++1y 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
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

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