Skip to content

Patch false maybe-uninitialized warning#2102

Merged
lerno merged 1 commit intoc3lang:masterfrom
hyperpastel:i686-fix
Apr 20, 2025
Merged

Patch false maybe-uninitialized warning#2102
lerno merged 1 commit intoc3lang:masterfrom
hyperpastel:i686-fix

Conversation

@hyperpastel
Copy link
Copy Markdown
Contributor

Cross compiling c3c for Linux i686 for void-pkgs fails due to a -Werror=maybe-uninitialized warning generated in src/compiler/sema_expr.c

2025-04-18T08:05:33.9357799Z /usr/bin/cc -DCURL_FOUND=0 -DLLVM_AVAILABLE=1 -DTB_AVAILABLE=0 -I/builddir/c3c-0.7.0/src -I/builddir/c3c-0.7.0/build -I/builddir/c3c-0.7.0/wrapper/include -I/builddir/c3c-0.7.0/dependencies/miniz -I /usr/include/libxml2 -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=i686 -O2    -ffile-prefix-map=/builddir/c3c-0.7.0/build=. -std=gnu11   -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -pthread -Wall -Werror -Wno-unknown-pragmas -Wno-unused-result -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -MD -MT CMakeFiles/c3c.dir/src/compiler/sema_expr.c.o -MF CMakeFiles/c3c.dir/src/compiler/sema_expr.c.o.d -o CMakeFiles/c3c.dir/src/compiler/sema_expr.c.o -c /builddir/c3c-0.7.0/src/compiler/sema_expr.c
2025-04-18T08:05:33.9363205Z In function 'sema_expr_analyse_swizzle',
2025-04-18T08:05:33.9363970Z     inlined from 'sema_expr_analyse_access' at /builddir/c3c-0.7.0/src/compiler/sema_expr.c:5270:11:
2025-04-18T08:05:33.9365451Z /builddir/c3c-0.7.0/src/compiler/sema_expr.c:5009:28: error: 'index' may be used uninitialized [-Werror=maybe-uninitialized]
2025-04-18T08:05:33.9366360Z  5009 |                 if ((index ^ val) & 0x10)
2025-04-18T08:05:33.9366794Z       |                     ~~~~~~~^~~~~~
2025-04-18T08:05:33.9367437Z /builddir/c3c-0.7.0/src/compiler/sema_expr.c: In function 'sema_expr_analyse_access':
2025-04-18T08:05:33.9368361Z /builddir/c3c-0.7.0/src/compiler/sema_expr.c:4996:13: note: 'index' was declared here
2025-04-18T08:05:33.9369023Z  4996 |         int index;
2025-04-18T08:05:33.9369345Z       |             ^~~~~
2025-04-18T08:05:33.9369715Z cc1: all warnings being treated as errors

This PR addresses this by default initializing index to 0

@lerno lerno merged commit 6ab7953 into c3lang:master Apr 20, 2025
41 checks passed
@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Apr 20, 2025

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants