[Bug c++/92340] New: Qualifiers check fails when inside template

2019-11-03 Thread ercli at ucdavis dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92340

Bug ID: 92340
   Summary: Qualifiers check fails when inside template
   Product: gcc
   Version: 9.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ercli at ucdavis dot edu
  Target Milestone: ---

Created attachment 47161
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47161&action=edit
The program that causes the bug

System information: 

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC) 

To trigger the bug, go to the directory of a.cpp, and type:

g++ a.cpp

Compiler output:

a.cpp: In function 'void f1()':
a.cpp:12:2: error: cannot convert '#'addr_expr' not supported by
dump_type#' to 'C*'
   12 |  c.f();
  |  ^
  |  |
  |  #'addr_expr' not supported by dump_type#
a.cpp:5:8: note:   initializing argument 'this' of 'void C::f()'
5 |   void f() {}
  |^

The error description seems to be incorrect. If line 8 in a.cpp (starts with
"template") is commented, the error message looks more correct:

a.cpp: In function 'void f1()':
a.cpp:12:6: error: passing 'const C' as 'this' argument discards qualifiers
[-fpermissive]
   12 |  c.f();
  |  ^
a.cpp:5:8: note:   in call to 'void C::f()'
5 |   void f() {}
  |^
a.cpp: In function 'int main()':
a.cpp:16:5: error: expected primary-expression before 'int'
   16 |  f1();
  | ^~~

[Bug c++/92340] Qualifiers check fails when inside template

2019-11-03 Thread ercli at ucdavis dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92340

--- Comment #1 from ercli at ucdavis dot edu ---
Created attachment 47162
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47162&action=edit
Compiler generated file using -save-temps

[Bug c++/92340] Qualifiers check fails when inside template

2019-11-03 Thread ercli at ucdavis dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92340

--- Comment #2 from ercli at ucdavis dot edu ---
Created attachment 47163
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47163&action=edit
Compiler generated file using -save-temps

[Bug c/105100] New: Strange warning when modifying structures "writing 1 byte into a region of size 0" when compile with -O3

2022-03-29 Thread ercli at ucdavis dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105100

Bug ID: 105100
   Summary: Strange warning when modifying structures "writing 1
byte into a region of size 0" when compile with -O3
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ercli at ucdavis dot edu
  Target Milestone: ---

Created attachment 52715
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52715&action=edit
Preprocessor output that triggers the bug

I am compiling a function that reads a byte array and converts it to
structures. I find strange compiler warnings when using -O3 optimization.

See attachment from line 10 for a minimize test case. My source code is named
b.c, which does not contain any includes.

The exact version of GCC:
gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Also see compiler output below

The system type:
Fedora 35 Workstation, kernel 5.16.16-200.fc35.x86_64

The options given when GCC was configured/built:
See compiler output below

The complete command line that triggers the bug:
gcc -v -save-temps -O3 -Wall -Werror -c -o b.o b.c

The compiler output (error messages, warnings, etc.):
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-Wall' '-Werror' '-c' '-o' 'b.o'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/11/cc1 -E -quiet -v b.c -mtune=generic
-march=x86-64 -Wall -Werror -O3 -fpch-preprocess -o b.i
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/11/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/11/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/11/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-Wall' '-Werror' '-c' '-o' 'b.o'
'-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/11/cc1 -fpreprocessed b.i -quiet
-dumpbase b.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O3 -Wall -Werror
-version -o b.s
GNU C17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP
version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 11.2.1 20220127 (Red Hat 11.2.1-9) (x86_64-redhat-linux)
compiled by GNU C version 11.2.1 20220127 (Red Hat 11.2.1-9), GMP
version 6.2.0, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 8878ef997f8884938fae95d09b5e3a52
b.c: In function 'func':
b.c:28:31: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]
   28 | pb[i] = src[0];
  | ~~^~~~
b.c:9:18: note: at offset 2 into destination object 'a' of size 2
9 | uint16_t a;
  |  ^
b.c:28:31: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]
   28 | pb[i] = src[0];
  | ~~^~~~
b.c:9:18: note: at offset 3 into destination object 'a' of size 2
9 | uint16_t a;
  |  ^
cc1: all warnings being treated as errors

[Bug c/107663] New: GCC does not catch -Werror=maybe-uninitialized that looks apparent

2022-11-12 Thread ercli at ucdavis dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107663

Bug ID: 107663
   Summary: GCC does not catch -Werror=maybe-uninitialized that
looks apparent
   Product: gcc
   Version: 12.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ercli at ucdavis dot edu
  Target Milestone: ---

Created attachment 53890
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53890&action=edit
a.i - the preprocessed file that triggers the bug

When compiling the following function, GCC with -Wall gives no warnings.
However, it looks clear to me that line 14 uses uninitialized variable declared
in line 13.

void func(int *p)
{
 if (f_a()) {
  int v;  /* line 13 */
  *p = v; /* line 14 */
  f_b(&v);
 }
}

GCC does not output anything in stdout and stderr. I think this is a false
negative: GCC fails to detect uninitialized use of variable. Expected warning
message looks like:

b.c: In function 'func':
b.c:8:20: error: 'v' is used uninitialized [-Werror=uninitialized]
8 | *p = v;
  | ~~~^~~
b.c:7:21: note: 'v' declared here
7 | int v;
  | ^
cc1: all warnings being treated as errors

To reproduce this bug, use the file "a.i" attached with this bug. The compile
command is "gcc -c -Wall -Werror a.i".

My system information can be retrieved below (output of "gcc -v -save-temps
-Wall -Werror -c a.c"):

Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-12.2.1-20220819/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.1 20220819 (Red Hat 12.2.1-2) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Werror' '-c' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/12/cc1 -E -quiet -v a.c -mtune=generic
-march=x86-64 -Wall -Werror -fpch-preprocess -o a.i
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/12/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/12/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Werror' '-c' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/12/cc1 -fpreprocessed a.i -quiet
-dumpbase a.c -dumpbase-ext .c -mtune=generic -march=x86-64 -Wall -Werror
-version -o a.s
GNU C17 (GCC) version 12.2.1 20220819 (Red Hat 12.2.1-2) (x86_64-redhat-linux)
compiled by GNU C version 12.2.1 20220819 (Red Hat 12.2.1-2), GMP
version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 12.2.1 20220819 (Red Hat 12.2.1-2) (x86_64-redhat-linux)
compiled by GNU C version 12.2.1 20220819 (Red Hat 12.2.1-2), GMP
version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version
isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 816b60f1f61bd59efac4d324ea795f15
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Werror' '-c' '-mtune=generic'
'-march=x86-64'
 as -v --64 -o a.o a.s
GNU assembler version 2.37 (x86_64-redhat-linux) using BFD version version
2.37-36.fc36
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Werror' '-c' '-mtune=generic'
'-march=x86-64'