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

            Bug ID: 123882
           Summary: [16 Regression] build failure of wlroots-0.19.2:
                    invalid use of 'restrict'
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Today's gcc from r16-7160-g41f293e72c2533 (did not bisect) fails to build
wlroots-0.19.2 as:

wlroots> FAILED: [code=1] libwlroots-0.19.so.p/backend_drm_util.c.o
wlroots> gcc -Ilibwlroots-0.19.so.p -I. -I.. -Iinclude -I../include -Iprotocol
-Irender/gles2/shaders -Irender/vulkan/shaders -Ibackend/drm
-I/nix/store/ql5ymq7dbb2nyqy8mm1g3cg4cy104ch2-wayland-1.24.0-dev/include
-I/nix/store/g40r7lrdjs8bxzxc0d8a93r86440z870-libdrm-2.4.131-dev/include
-I/nix/store/g40r7lrdjs8bxzxc0d8a93r86440z870-libdrm-2.4.131-dev/include/libdrm
-I/nix/store/jknms4pmad43dfi4g1dppfqvkmf31x8j-libxkbcommon-1.11.0-dev/include
-I/nix/store/biivv769az7mqi6098cmrwdrzlvd4pw8-pixman-0.46.4/include/pixman-1
-I/nix/store/rhdp8n01fcjg2zyyr62azz4c3ih1pza4-libglvnd-1.7.0-dev/include
-I/nix/store/cra07qja9xf2kag23bi8qzz2nqfmjnps-mesa-libgbm-25.1.0/include
-I/nix/store/h1a15dhrifjfgicixvzyndhm4ys0bd02-vulkan-headers-1.4.335.0/include
-I/nix/store/c20nm3wsqqcnk72y2dm90qxxashq99xi-lcms2-2.18-dev/include
-I/nix/store/vvy4dgkgfc0rbsnliflrxcjf781c02ph-systemd-minimal-libs-258.3-dev/include
-I/nix/store/fz30aryf4a2h82pshq0zl0j6jmkg4466-seatd-0.9.2-dev/include
-I/nix/store/4jrxcj1l65sw5a5mv0fk0cp6xkjhcivf-libdisplay-info-0.3.0/include
-I/nix/store/hmaqmzl3bnb8gk3dzr54safx2rk859xx-libliftoff-0.5.0/include
-I/nix/store/lmhn2gjjjk7n8hywfk8byid8mcyxygag-libinput-1.29.2-dev/include
-I/nix/store/250n3xg3i99dnpw073zapnlsb79mlcsz-libxcb-1.17.0-dev/include
-I/nix/store/r2y6gxcwr72y3z1r6283x6b10ihj71q6-libxcb-render-util-0.3.10-dev/include
-I/nix/store/yxgrxcl9sjfmqwkcrrd3a7cdr2kwqa12-libxcb-wm-0.4.2-dev/include
-I/nix/store/2zjq1sz3kfmzlhmaxy2gf3sg4z8zm2gp-libxcb-errors-1.0.1-dev/include
-fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra
-Werror -std=c23 -D_POSIX_C_SOURCE=200809L -DWLR_USE_UNSTABLE -DWLR_PRIVATE=
-DWLR_LITTLE_ENDIAN=1 -DWLR_BIG_ENDIAN=0 -Wundef -Wlogical-op
-Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self
-Wstrict-prototypes -Wimplicit-fallthrough=2 -Wendif-labels -Wstrict-aliasing=2
-Woverflow -Wmissing-prototypes -Walloca -Wno-missing-braces
-Wno-missing-field-initializers -Wno-unused-parameter -fmacro-prefix-map=../=
-fPIC -MD -MQ libwlroots-0.19.so.p/backend_drm_util.c.o -MF
libwlroots-0.19.so.p/backend_drm_util.c.o.d -o
libwlroots-0.19.so.p/backend_drm_util.c.o -c ../backend/drm/util.c
wlroots> ../backend/drm/util.c:219:17: error: invalid use of 'restrict'
wlroots>   219 |                 uint32_t new_crtcs[static restrict num_crtcs])
{
wlroots>       |                 ^~~~~~~~



Original code:L
https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/backend/drm/util.c?ref_type=heads#L241

Attempted to extract the reproducer:

$ cat /tmp/bug.c.c
typedef int uint32_t;
void match_connectors_with_crtcs(unsigned long, uint32_t[]);
void match_connectors_with_crtcs(unsigned long num_crtcs,
                                 uint32_t[restrict num_crtcs]);

$ gcc/xgcc -Bgcc  -c /tmp/bug.c.c
/tmp/bug.c.c:4:34: error: invalid use of ‘restrict’
    4 |                                  uint32_t[restrict num_crtcs]);
      |                                  ^~~~~~~~

Fun fact: inlining `typedef int uint32_t;` makes the error go away.

$ gcc/xgcc -Bgcc  -v
Reading specs from gcc/specs
COLLECT_GCC=gcc/xgcc
COLLECT_LTO_WRAPPER=gcc/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/slyfox/dev/git/gcc/configure --disable-multilib
--disable-bootstrap --disable-lto --disable-libsanitizer
--disable-libstdcxx-pch --enable-languages=c,c++ --disable-libgomp
--disable-libquadmath --disable-libvtv CFLAGS='-O1 -g0' CXXFLAGS='-O1 -g0'
LDFLAGS='-O1 -g0'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.1 20260129 (experimental) (GCC)

Reply via email to