Skip to content

-Wuninitialized suggests = 0 for enums #9515

@nico

Description

@nico
Bugzilla Link 9143
Resolution FIXED
Resolved on Feb 04, 2011 19:19
Version trunk
OS All
CC @tkremenek

Extended Description

hummer:src thakis$ cat test.cc
enum A {
A_a, A_b
};
A f() {
A a;
return a;
}

hummer:src thakis$ ~/src/llvm-svn/Release+Asserts/bin/clang -c test.cc -Wall
test.cc:6:10: warning: variable 'a' is possibly uninitialized when used here [-Wuninitialized]
return a;
^
test.cc:5:3: note: variable 'a' is declared here
A a;
^
test.cc:5:6: note: add initialization to silence this warning
A a;
^
= 0
1 warning generated.

But doing this is of course not valid:

hummer:src thakis$ cat test.cc
enum A {
A_a, A_b
};
A f() {
A a = 0;
return a;
}
hummer:src thakis$ ~/src/llvm-svn/Release+Asserts/bin/clang -c test.cc -Wall
test.cc:5:5: error: cannot initialize a variable of type 'A' with an rvalue of type 'int'
A a = 0;
^ ~
1 error generated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions