Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wuninitialized warning on empty struct #26842

Closed
hjl-tools opened this issue Feb 4, 2016 · 2 comments
Closed

-Wuninitialized warning on empty struct #26842

hjl-tools opened this issue Feb 4, 2016 · 2 comments
Labels
bugzilla Issues migrated from bugzilla c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party false-positive Warning fires when it should not

Comments

@hjl-tools
Copy link
Contributor

Bugzilla Link 26468
Version trunk
OS Linux

Extended Description

[hjl@gnu-6 empty-2]$ cat x.c
struct empty {};

struct empty
foo (void)
{
struct empty s;
return s;
}
[hjl@gnu-6 empty-2]$ make
/export/build/gnu/llvm-clang-bootstrap/stage1/build-x86_64-linux/bin/clang -m32 -S -O -Wall x.c
x.c:7:10: warning: variable 's' is uninitialized when used here
[-Wuninitialized]
return s;
^
x.c:6:3: note: variable 's' is declared here
struct empty s;
^
1 warning generated.
[hjl@gnu-6 empty-2]$

Shouldn't empty struct be a special case here?

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@AaronBallman AaronBallman added confirmed Verified by a second party c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer false-positive Warning fires when it should not labels Jun 14, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 14, 2023

@llvm/issue-subscribers-c

@EugeneZelenko EugeneZelenko removed the clang Clang issues not falling into any other category label Jun 14, 2023
@AaronBallman
Copy link
Collaborator

We're also diagnosing the case where all the fields are unnamed bit-fields or zero-length bit-fields when we shouldn't be. GCC warns on none of:

struct One {};
struct Two { int : 0; };
struct Three { int : 12 };

https://godbolt.org/z/4E771zM5Y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

4 participants