https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121369
Bug ID: 121369
Summary: Error instead of warning for
-Wincompatible-pointer-types?
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: diagnostics
Assignee: dmalcolm at redhat dot com
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/Ef7Y8dxPe
13.* and earlier give a warning, while 14.* and later issue an error.
Unsure whether it was intended or not.
[521] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250802 (experimental) (GCC)
[522] %
[522] % gcctk -c small.c
small.c: In function ‘c’:
small.c:3:18: error: pointer type mismatch in conditional expression
[-Wincompatible-pointer-types]
3 | void c() { 0 ? a : b; }
| ^
small.c:3:16: note: first expression has type ‘int *’
3 | void c() { 0 ? a : b; }
| ^
small.c:3:20: note: second expression has type ‘char *’
3 | void c() { 0 ? a : b; }
| ^
[523] % gcc-
gcc-11 gcc-ar gcc-ar-12 gcc-nm-11 gcc-ranlib
gcc-ranlib-12
gcc-12 gcc-ar-11 gcc-nm gcc-nm-12 gcc-ranlib-11
[523] % gcc-12 -c small.c
small.c: In function ‘c’:
small.c:3:18: warning: pointer type mismatch in conditional expression
3 | void c() { 0 ? a : b; }
| ^
[524] % cat small.c
int *a;
char *b;
void c() { 0 ? a : b; }