Skip to content

[-Wunused-but-set-variable] False negative with static global variable #148361

@alejandro-colomar

Description

@alejandro-colomar
static int foo;

int
main(void)
{
	foo = 42;
}
alx@devuan:~/tmp$ clang -Weverything static.c 
alx@devuan:~/tmp$ 

I think this should trigger some diagnostic. The compiler is able to see that the variable is set, but never used.

Or is it too complex to gather such information about a static global?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions