llvm/llvm-project

c11: Accepts ill-formed program with inline function definition containing modifiable variable with static storage duration.

Open

#39.524 geöffnet am 28. Dez. 2018

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
bugzillacclang:diagnosticsconfirmedgood first issue

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

Bugzilla Link 40177
Version trunk
OS All
CC @hfinkel,@zygoloid

Extended Description

Test case (prog.c):

inline void f() { static int x; }

int main() { }

Compilation command line:

clang prog.c -Wall -Wextra -std=c11 -pedantic-errors

Observed behaviour:

No error message outputed. Only a warning message outputed.

Expected behaviour:

An error message outputed.

The program violates 6.7.4/3:

"An inline definition of a function with external linkage shall not contain
 a definition of a modifiable object with static or thread storage duration,
 and shall not contain a reference to an identifier with internal linkage."

Since -pedantic-errors is used we should get an error instead of a warning.

Note:

GCC gives the expected error message.

Contributor Guide