Did your compiler already promote the first batch?
Most teams planning a "warnings to errors" migration on an old C repo think they're choosing when to start. They aren't. GCC 14 already did the first round for them: implicit int, implicit function declarations, missing parameter types, return mismatches, integer/pointer conversions and incompatible pointer types all became errors by default, according to GCC's own "Porting to GCC 14" notes. Then GCC 15 changed the default C dialect from -std=gnu17 to -std=gnu23, where int f(); means "takes no arguments". Old code that declared functions that way breaks without anyone touching a flag. For the older history of C++ tooling, see Debugging C++ on Linux.
So the real question isn't whether to promote. What's left to promote, in what order, and how do you stop the pile from growing while you work through it?
I don't have a twenty-year C repo to show you, and I'm not going to pretend otherwise. What I did instead was smaller and fully reproducible: I wrote a 55-line file stuffed with pre-C99 habits (K&R definitions, a function with implicit int, strlen without <string.h>, an integer assigned to a pointer, a switch that falls through, a variable read before it's set) and compiled it under several settings with Homebrew GCC 15.2.0 and Apple clang 17.0.0 on an arm64 Mac.
How did one file get seven different verdicts?
| Build | Errors | Warnings | Compiles? |
|---|---|---|---|
gcc-15 (default, gnu23) |
9 | 4 | no |
gcc-15 -std=gnu17 |
6 | 2 | no |
gcc-15 -std=gnu17 -Wall -Wextra |
6 | 7 | no |
gcc-15 -std=gnu17 -fpermissive -Wall -Wextra |
0 | 13 | yes |
gcc-15 -std=gnu89 |
0 | 4 | yes |
Apple clang (default) |
5 | 4 | no |
Apple clang -std=gnu17 -Wall -Wextra -Werror |
14 | 0 | no |
Three of those rows deserve a second look.
The default GCC 15 build threw 9 errors at 55 lines of old C, and three of them came from something no earlier GCC would have rejected. My file declares int parse_flags(); and defines it K&R-style with two parameters. Under gnu23 that declaration is a zero-argument prototype, so GCC reports "number of arguments doesn't match prototype" and, at the call site, "too many arguments to function 'parse_flags'; expected 0, have 2". Clang at its default dialect only warns about it, with -Wdeprecated-non-prototype.
The -std=gnu89 row is the dangerous one. Zero errors. Four warnings. And yet the file still reads flags before assigning it, calls memcpy with no declaration and stores 42 in a char *. GCC's porting notes are blunt that the gnu89 and c89 modes also switch pre-standard constructs back on, and that's exactly what happened.
Then the uninitialized read. With -Wall -Wextra at the default -O0, GCC 15 said nothing about flags |= 1 operating on garbage. Rebuild at -O2 and -Wmaybe-uninitialized fires twice. That isn't a GCC bug; the manual says those warnings "are only possible in optimizing compilation". Clang caught the same line at -O0 through -Wuninitialized.
What does that mean for a gate? The debug CI job passes, the release job fails, same commit.
Why is blanket -Werror a bet on your next compiler?
The two compilers didn't even agree on what -Wextra covers. On a separate clean file with a single unannotated fall-through, GCC's -Wextra warned (the manual says -Wimplicit-fallthrough=3 is part of it); clang's -Wall -Wextra stayed silent until I added -Wimplicit-fallthrough by hand. Flag names don't line up perfectly either. Apple clang flagged -Werror=declaration-missing-parameter-type as an unknown warning option, and under a blanket -Werror an unknown-option warning is one more error.
Linus Torvalds made -Werror the kernel default on 5 September 2021, and his commit message already names the catch: "new compiler versions end up enabling new warnings". Today init/Kconfig defaults CONFIG_WERROR to COMPILE_TEST only, and its help text tells anyone with "a new (or very old) compiler" to turn it off. If the kernel can't keep blanket -Werror on for every build, your 1998 parser won't either.
Google's answer, in the static analysis chapter of Software Engineering at Google, is stricter than most teams expect: "We have found repeatedly that developers ignore compiler warnings." So a check either breaks the build or doesn't appear. It gets to break the build only if it's actionable, produces "no effective false positives" and is about correctness rather than style, and only after every existing instance in the codebase has been cleaned up.
A warning your team has seen for three years is not a warning anymore. Promote it to an error or delete the flag.
That's my position, and plenty of C shops would call it naive. Warnings as a to-do list feel harmless. They aren't; they're the reason -Wsign-compare output scrolls past unread in CI logs for a decade.
Which warnings do real repos trip over most?
My file can't tell you what's common in the wild. Fedora can. When Florian Weimer at Red Hat ran the "Porting Fedora to Modern C" change ahead of GCC 14, the wiki tracked how many packages still needed fixes on 2023-11-29:
- incompatible pointer types: about 381 packages, status "barely begun"
- integer/pointer conversions: about 100
- implicit function declarations: 54
returnstatement mismatches: about 13- implicit
int: 5
Those are packages still broken at that date, after earlier work, not a census of how often each warning appears. Still, the order is useful. Implicit declarations had years of attention; pointer-type mismatches were the long tail. Expect the same in your repo.
In what order should you promote them?
Tier 1, promote explicitly now. Even though GCC 14+ already errors on these, write them down, so older GCC builds and clang agree with your newest compiler:
CFLAGS += -std=gnu17 -Wall -Wextra \
-Werror=implicit-function-declaration \
-Werror=implicit-int \
-Werror=int-conversion \
-Werror=incompatible-pointer-types \
-Werror=return-type
Pinning -std=gnu17 is deliberate. It buys time before gnu23's prototype rules land, and it makes the dialect a decision rather than a side effect of a toolchain upgrade.
Tier 2, clean up first, then promote. -Werror=uninitialized and -Werror=implicit-fallthrough pass Google's test for correctness, but both need work first: annotate intentional fall-throughs, and pick the optimization level the gate runs at, because you've seen that it changes the verdict.
Tier 3, leave as warnings under a ratchet. -Wsign-compare, -Wunused-parameter, -Wunused-variable. Are they real? Sure. They're just not what breaks production, and promoting them early is how you get a week of (void)argc; commits and nothing learned.
A ratchet for everything you haven't promoted
A ratchet doesn't demand zero. It demands "no worse than yesterday", per flag. This is the script used against the 55-line test file; swap the compile line for your real build:
gcc-15 -std=gnu17 -fpermissive -Wall -Wextra -c legacy.c -o /dev/null 2> build.log
grep -o '\[-W[a-z0-9=-]*\]' build.log | sort | uniq -c | awk '{ print $2, $1 }' > warnings-now.txt
status=0
while read -r flag count; do
allowed=$(awk -v f="$flag" '$1 == f { print $2 }' warnings-baseline.txt)
if [ -z "$allowed" ]; then
allowed=0
fi
if [ "$count" -gt "$allowed" ]; then
echo "RATCHET FAIL: $flag $allowed -> $count"
status=1
fi
done < warnings-now.txt
exit $status
The first run wrote a baseline of nine flags. Then I appended a five-line function with an unused parameter and an unused local, and the gate failed with -Wunused-parameter 1 -> 2 and -Wunused-variable 2 -> 3. Lower the baseline file whenever someone fixes something, and commit it. That's the whole mechanism.
For clang-tidy the pieces already exist: --warnings-as-errors takes the same glob syntax as -checks, and clang-tidy-diff.py reports only on changed lines (it still analyzes the whole file, the docs note, then filters). New code meets the error bar; old code meets the ratchet.
What is -fpermissive for?
A way to get the build green on the day you upgrade compilers, and nothing more. In my run it turned 6 errors into 13 warnings, and every one of those warnings pointed at a habit I'd planted in the file on purpose. Nothing got fixed. It just got quieter. If -fpermissive or -std=gnu89 is still in your CFLAGS six months from now, ask yourself honestly: is that a migration, or the old warnings wearing a new flag?
If you're deciding where this gate sits among the others, I ranked it against the twelve CI gates I add first. And if your repo already carries a forest of #pragma GCC diagnostic ignored, read up on lint suppression creep before you promote anything, because a promoted warning is exactly what people learn to silence. I ran the same idea on a bigger tree in a 24,000-line C gate, where 41 silenced sites hid 7 real defects, two of them crashes.