Skip to content

I Ran Every Check From the 1978 Lint Paper Through gcc and clang

I turned the 1978 lint paper into 42 C snippets. gcc 13 and clang 18 flag 15 with no flags, 28 with opt-in flags, and 13 not at all, analyzers included.

· · 14 min read
Bar chart of 42 checks from the 1978 lint paper by cheapest flagging level: 15 with no flags, 13 by nothing

Where is the 1978 paper, and what does it list?

Every linter you've ever installed borrows its name from one program. Lint was written by Stephen C. Johnson at Bell Labs, and the paper that describes it, "Lint, a C Program Checker", shipped in volume 2 of the Seventh Edition Unix manual. The troff source is still online at 9p.io, dated July 26, 1978. I fetched it (32,431 bytes) and read it end to end, because I wanted the original list, not the version people half remember.

The abstract says what lint was for in one line: it "enforces the type rules of C more strictly than the C compilers." And the paper's last section explains why that was a separate program at all. The compiler can be fast, Johnson writes, "since it knows that lint will cover its flanks."

That's the bet I wanted to check. Forty-eight years later, did the compiler absorb the flanks, or are we still running two programs and calling the second one by a different name?

The paper is prose, not a rule table. It has sections named "Unused Variables and Functions", "Set/Used Information", "Flow of Control", "Function Values", "Type Checking", "Type Casts", "Nonportable Character Use", "Assignments of longs to ints", "Strange Constructions", "Ancient History", "Pointer Alignment", "Multiple Uses and Side Effects", "Portability" and "Library Declaration Files". The source has no page numbers, so everything below cites those headings.

I split them into 42 testable checks. Another reader could count 38 or 50; I split where the paper gives a separate example or a separate message. Lint also had options: -h for "heuristic" checks like null effects and precedence, -p for portability, -a for long-to-int, -c for casts, -b for unreachable break, -x for unused externs. I recorded which option each check needed, because "lint did it by default" and "lint did it if you asked" aren't the same claim.

How did I test 42 checks against two compilers?

Each check became the smallest C file that triggers it. Here's the paper's own example from "Function Values", almost verbatim, plus a prototype for g:

void g(void);

int f(int a)
{
	if (a)
		return 3;
	g();
}

Five checks only make sense across files, because lint compared every definition and call in the whole program. Those became pairs of files, compiled and linked together.

Tools, on a Linux box (x86_64, Ubuntu 24.04 packages): gcc 13.3.0 (13.3.0-6ubuntu2~24.04.1), clang 18.1.3 (1ubuntu1), both at their default -std=gnu17, and cppcheck 2.13.0. Levels per compiler: no flags, -Wall, -Wall -Wextra, an opt-in level, and the compiler's own analyzer (gcc -fanalyzer, clang --analyze). The opt-in level for gcc is a fixed list of 11 extra flags including -Wshadow, -Wconversion and -Wcast-align=strict; for clang it's -Weverything. I also ran gcc -O2 -Wall -Wextra (identical results to -O0 on all 42) and a gcc LTO link for the cross-file pairs.

The first pass marks a level as flagging a case when it prints any warning or error. That over-counts, so I read every diagnostic. Twenty results got relabelled: a dead-store warning on the getchar() line isn't the char-signedness check, and -Wstrict-prototypes on a declaration is a hint at an argument mismatch, not a report of it. Those count as "indirect" or "no", never as a catch. Everything, including the 42 files and the relabelling table with a reason per row, is in examples/lint-1978-checks-what-gcc-and-clang-catch-now/. The full run takes about 17 seconds.

What does a compiler flag today with no flags at all?

More than I expected, and very unevenly.

# Check (paper section) lint option gcc 13.3 clang 18.1 cppcheck 2.13
01 Unused local (Unused Variables) default -Wall -Wall --enable=all
02 Unused argument default -Wextra -Wextra -
03 Unused static function default -Wall -Wall --enable=all
04 External function never called, 2 files default - - --enable=all
05 Unused extern declaration -x - - -
06 Used before set (Set/Used) default -Wall -Wall default
07 Set, never used default -Wall -Wall --enable=all
08 Statement after return (Flow of Control) default - opt-in --enable=all
09 Statement after for(;;) default - opt-in -
10 Loop not entered at the top default - - -
11 Unreachable break -b - opt-in -
12 return(e) and bare return (Function Values) default default error -
13 Falls off the end default -Wall default -
14 Return value always ignored default - - -
15 Value used from a void function, 2 files default indirect indirect -
16 Pointer types disagree (Type Checking) default default default -
17 Member of the wrong struct default error error -
18 Argument type vs definition, 2 files default indirect indirect -
19 Argument count vs definition, 2 files default indirect indirect -
20 Enum mixed with another enum default -Wextra default -
21 Arithmetic on an enum default - - -
22 p = 1 into a char pointer (Type Casts) default default error -
23 p = (char *)1 -c - - -
24 char c = getchar(), then c < 0 none named opt-in opt-in -
25 Constant too big for a 2-bit field none named opt-in default -
26 long assigned to int -a opt-in opt-in -
27 *p++; null effect (Strange Constructions) -h -Wall default --enable=all
28 unsigned x < 0 -h -Wextra opt-in --enable=all
29 unsigned x > 0 -h - - -
30 if (1 != 0) -h - indirect -
31 x & 077 == 0 -h -Wall default --enable=all
32 x << 2 + 40 -h -Wall default -
33 Inner block redeclares a variable -h opt-in opt-in --enable=all
34 a =-1 (Ancient History) none named - - -
35 int x 1; none named error error -
36 int * cast to double * (Pointer Alignment) -p or -h opt-in opt-in indirect
37 a[i] = b[i++] (Multiple Uses) none named -Wall default default
38 Same uninitialized external in 2 files (Portability) -p link error link error -
39 Externals equal after 6 chars, one case -p - - -
40 'ab' multi-character constant none named default default -
41 Redefining a library routine, abs default - - -
42 atoi(42) against the library (Library Declaration Files) default default error -

Each cell is the cheapest level that flagged the check. "error" means no flags were needed and the build stopped.

gcc 13.3 flags 8 of the 42 with no flags. Clang 18.1 flags 15. Six stop the build in at least one compiler: the wrong struct member and the old int x 1; initializer are plain syntax and type errors in both, and clang refuses return; in an int function, p = 1 and atoi(42) (the integer-to-pointer pair has been an error by default since clang 15). The duplicated external in two files fails at the link.

That last one is my favourite. Lint caught it under -p, because the GCOS and IBM loaders of 1978 couldn't merge two int a; definitions. Unix's loader could, and so could gcc until version 10, which switched to -fno-common by default. I checked: the same pair links without a word under -fcommon in both compilers. A portability warning from 1978 became a hard error in 2020 for a different reason, and nobody had to opt in.

Clang's lead at the bottom of the ladder comes from defaults. Falling off the end of an int function, mixing two enums, the bit-field overflow, *p++;, both precedence traps and a[i] = b[i++] are all on in clang without a flag, and need at least -Wall in gcc. Want the stricter compiler for free? On these 42, it's clang.

What does -Wall -Wextra add, and what's still opt-in?

-Wall adds four across the two compilers: the unused local, the unused static function, use before set and set-but-never-used. -Wextra adds two: the unused parameter and unsigned < 0. That's 21 of 42 for the flags most teams think of as "the warnings". The other half of the paper is past them.

Line chart of 1978 lint checks flagged by gcc 13.3 and clang 18.1 at each warning level, from 8 and 15 up to 28
Cumulative count of the 42 lint checks each compiler flags as you add warning levels. The analyzer step adds nothing for either compiler.

Seven more need a flag you have to name. Here's what fired:

Check gcc 13.3 clang 18.1
Statement after return or for(;;) nothing -Wunreachable-code
Unreachable break nothing -Wunreachable-code-break
char from getchar() -Wconversion -Wimplicit-int-conversion
long to int -Wconversion -Wshorten-64-to-32
Inner-block redeclaration -Wshadow -Wshadow
int * to double * -Wcast-align=strict -Wcast-align

gcc accepts -Wunreachable-code and prints nothing on any of the three unreachable cases; I ran it separately to make sure. If your gate is gcc-only, lint's whole "Flow of Control" section is invisible to it.

The char case taught me the most. Lint's complaint was that if ((c = getchar()) < 0) works on the PDP-11, where char is signed, and fails on machines where it isn't. On x86_64 char is signed, so -Wall -Wextra in gcc says nothing. Add -funsigned-char to mimic an ARM target and the same gcc level prints "comparison is always false due to limited range of data type". Clang at -Wall -Wextra stays quiet either way. The warning you get depends on the machine you compile on, which is exactly the portability problem lint was written about.

Did the analyzers find anything the compilers missed?

No. That's the result I'd least have predicted.

gcc -fanalyzer flagged 9 cases, and 8 of those were the compiler's default warnings riding along; the ninth, use before set, -Wall already has. clang --analyze flagged 7: the five hard errors, the garbage value from use before set, and a dead store on the set-but-unused variable. -Wall reports both of those last two already. Neither added a single lint check to its compiler's opt-in level.

Cppcheck at its default settings reported 2 (use before set and the evaluation order). With --enable=all --inconclusive it reported 11, and one of them nothing else found: the external function defined in one file and called from nowhere, through its whole-program unusedFunction check. That's the only check in the whole run that sits in the "analyzer only" tier.

Does that mean analyzers are useless? Of course not. They're built for path-sensitive bugs like leaks, null dereferences and buffer overruns, and none of those were in a 1978 paper about type rules. But if you added -fanalyzer to a gate hoping to get "lint back", you didn't.

Which lint checks does nothing catch, 48 years later?

Thirteen. Seven of them lint ran by default:

  • A loop that can only be entered by goto into its middle.
  • A function whose return value is never used anywhere.
  • Arithmetic on an enum (lint allowed only =, ==, != and passing it around).
  • A library routine like abs redefined in your own code. Lint called the complaint "a feature".
  • And three across files: a value used from a function that returns none, a call with the wrong argument type, a call with the wrong argument count.

The other six are -x unused extern declarations, -c casts, unsigned > 0, if (1 != 0), the old =- operator, and external names that collide when cut to six characters of one case. A few of those died with the machines they protected. Mainstream linkers stopped truncating names to six characters long ago, and a =-1 has meant a = -1 for a long time.

The cross-file three haven't died. This is the pair for the argument count:

/* a.c */                      /* b.c */
int add(int a, int b)          int add();
{                              int main(void)
	return a + b;          {
}                                      return add(1);
                               }

Both compilers link it at every warning level. Clang prints -Wdeprecated-non-prototype even with no flags, which tells you the declaration style is old, not that the call is wrong. A gcc LTO build at -O2 -Wall -Wextra noticed something after inlining across the files: 'b' is used uninitialized. That's the consequence, found by accident.

C23 changes the picture, partly. In C23 int add(); means int add(void), so with -std=c2x gcc 13 and with -std=c23 clang 18 stop on add(1) with "too many arguments". GCC 15 makes C23 the default, according to its release notes. But read the message: clang says "expected 0, have 1". The real function takes two. The compiler is now checking the call against the wrong declaration, and the void-function pair still compiles and links clean under C23 and LTO. Lint compared the call against the definition. Nothing I ran does that.

What would I do with this?

Treat the compiler as the first lint, and pick the compiler on its defaults, not its feature list. On these 42, clang's no-flag level flags almost twice what gcc's does.

Put -Wshadow, -Wconversion and -Wcast-align in the gate deliberately. They're the bulk of the "still opt-in" tier, and they're opt-in because they're noisy, so promote them one flag at a time rather than all on a Friday. I've already shown three bugs -Wall -Wextra let through on a much smaller file; this run is the same lesson from the other end.

Fix cross-file consistency structurally, since no tool will do it for you. Every external function gets exactly one prototype in one header, included by its definition and by every caller. That's what C89 prototypes were for, and it's the only thing that closes rows 15, 18 and 19. Then add a whole-program check, cppcheck's unusedFunction or something heavier, in a nightly job.

My opinion, and you can disagree: lint "lost" by winning. Its checks were never deleted, they were spread across compiler defaults, -Wall, a dozen named flags and a linker default, and that's why nobody can say what their build actually checks. A suppression in that world doesn't silence a tool, it silences one flag nobody remembers enabling, which is how suppression creep starts.

What I didn't measure

  • The original lint. I didn't run the 1978 program, so the "lint option" column comes from the paper's text, not from lint's output on my snippets. Seven checks have no option named in their section.
  • My split of the paper. 42 is my count. Merging or splitting checks would move every number in the article.
  • Newer compilers. GCC 14 turns several of the default warnings here into errors (-Wreturn-mismatch, -Wint-conversion, -Wincompatible-pointer-types among them, per its porting notes), and GCC 15 defaults to C23. I measured gcc 13.3 and clang 18.1 only, which is what Ubuntu 24.04 ships.
  • Other tools. No clang-tidy, splint, CodeQL or PVS-Studio, and no clang LTO build.
  • Real code. Minimal snippets show whether a check exists, not how often it fires or how noisy it is on a real tree. The 24,000-line C gate is closer to that question.
  • Second reader. The relabelling of 20 results as "indirect" or "no" is my judgement; the reasons are listed in classify.py.

Frequently Asked Questions

Which checks from the original 1978 lint does a modern C compiler run by default?
Of 42 checks taken from Johnson's 1978 lint paper, gcc 13.3 flags 8 with no flags and clang 18.1 flags 15. They include mismatched pointer types, an integer assigned to a pointer, a function that falls off its end, ambiguous operator precedence and a[i] = b[i++]. Six of them are hard errors in at least one of the two compilers.
Do -Wall and -Wextra cover what lint used to check?
Partly. Across gcc 13.3 and clang 18.1, -Wall -Wextra flags 21 of the 42 checks. Unreachable code, shadowed variables, long-to-int truncation and pointer alignment need named flags such as -Wunreachable-code, -Wshadow, -Wconversion and -Wcast-align. Thirteen checks pass every level tested.
What did lint check that compilers still cannot?
Consistency across files. Lint compared every definition, declaration and call in the whole program, so a function called with the wrong number or type of arguments from another file, a value used from a void function, or an external function nobody calls got a message. gcc 13.3, clang 18.1 and their analyzers stay silent on these at every warning level.