This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60955] New: Erroneous warning about taking address of register with std=c++1y


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]