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

            Bug ID: 90640
           Summary: -Wpointer-arith appears to be enabled by default, but
                    is not reported by --help
           Product: gcc
           Version: 7.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gennaro.prota+gccbugzilla at gmail dot com
  Target Milestone: ---

The following program:

# 1 "pointer_arith_by_default.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "pointer_arith_by_default.cpp"
int
main()
{
    int a = 0 ;
    void * p = &a ;
    static_cast< void >( p + 1 ) ;
}

compiled, under Cygwin, with the command line below, gives (note the warning):

$ g++ -v -save-temps "pointer_arith_by_default.cpp"
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-7.4.0-1.x86_64/src/gcc-7.4.0
--prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc
--docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C
--build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib
--enable-shared --enable-shared-libgcc --enable-static
--enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit
--with-dwarf2 --with-tune=generic
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite
--enable-threads=posix --enable-libatomic --enable-libcilkrts --enable-libgomp
--enable-libitm --enable-libquadmath --enable-libquadmath-support
--disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
--without-libintl-prefix --with-system-zlib --enable-linker-build-id
--with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
gcc version 7.4.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/cc1plus.exe -E -quiet -v -idirafter
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/../include/w32api
-idirafter
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib/../lib/../../include/w32api
pointer_arith_by_default.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o
pointer_arith_by_default.ii
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/include"
ignoring duplicate directory
"/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib/../lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/x86_64-pc-cygwin
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/backward
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include
 /usr/include
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/../include/w32api
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/cc1plus.exe -fpreprocessed
pointer_arith_by_default.ii -quiet -dumpbase pointer_arith_by_default.cpp
-mtune=generic -march=x86-64 -auxbase pointer_arith_by_default -version -o
pointer_arith_by_default.s
GNU C++14 (GCC) version 7.4.0 (x86_64-pc-cygwin)
        compiled by GNU C version 7.4.0, GMP version 6.1.2, MPFR version
4.0.1-p11, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++14 (GCC) version 7.4.0 (x86_64-pc-cygwin)
        compiled by GNU C version 7.4.0, GMP version 6.1.2, MPFR version
4.0.1-p11, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fad625746d9e5a9fde6f0a54da0c00b5
pointer_arith_by_default.cpp: In function ‘int main()’:
pointer_arith_by_default.cpp:6:28: warning: pointer of type ‘void *’ used in
arithmetic [-Wpointer-arith]
     static_cast< void >( p + 1 ) ;
                          ~~^~~
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/as.exe -v
-o pointer_arith_by_default.o pointer_arith_by_default.s
GNU assembler version 2.29.1 (x86_64-pc-cygwin) using BFD version (GNU
Binutils) 2.29.1.20171006
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib/:/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/collect2.exe -plugin
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/cyglto_plugin.dll
-plugin-opt=/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/lto-wrapper.exe
-plugin-opt=-fresolution=pointer_arith_by_default.res
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lcygwin -plugin-opt=-pass-through=-ladvapi32
-plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32
-plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc --build-id -m i386pep --wrap _Znwm --wrap _Znam
--wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t --wrap
_ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKSt9nothrow_t
-Bdynamic --dll-search-prefix=cyg --tsaware
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/crt0.o
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-cygwin/7.4.0
-L/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/lib
-L/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../.. pointer_arith_by_default.o
-lstdc++ -lgcc_s -lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32
-lgcc_s -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/default-manifest.o
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/crtend.o
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'

However, the command

g++ -Q --help=warnings | fgrep pointer

gives:

  -Wincompatible-pointer-types          [enabled]
  -Wint-to-pointer-cast                 [enabled]
  -Wpointer-arith                       [disabled]
  -Wpointer-compare                     [enabled]
  -Wpointer-sign                        [disabled]
  -Wpointer-to-int-cast                 [enabled]
  -Wsizeof-pointer-memaccess            [disabled]
  -Wzero-as-null-pointer-constant       [disabled]

showing that -Wpointer-arith is disabled.

Reply via email to