NEW 118534
[buildfix] Fix build on gcc 4.8.1 when compiling with -Werror=maybe-uninitialized
https://bugs.webkit.org/show_bug.cgi?id=118534
Summary [buildfix] Fix build on gcc 4.8.1 when compiling with -Werror=maybe-uninitial...
Hugo Parente Lima
Reported 2013-07-10 10:54:58 PDT
The warning is triggered because an uint32_t:2 is used to hold and Enum, so when this variable is used in a switch the compiler think anything could be there. I'm aware that Efl builds with -Werror on, but those errors make me think if is better to compile with -Werror=no-maybe-uninitialized just to avoid patches like this one that doesn't help code wise and are here just make the compiler help.
Attachments
Patch (1.45 KB, patch)
2013-07-10 10:57 PDT, Hugo Parente Lima
ggaren: review-
Hugo Parente Lima
Comment 1 2013-07-10 10:57:56 PDT
Chris Dumez
Comment 2 2013-07-10 12:16:19 PDT
cc'ing JSC people.
Geoffrey Garen
Comment 3 2013-07-11 11:41:30 PDT
Comment on attachment 206399 [details] Patch I'd prefer to see "switch (static_cast<Enum>(info.mode))" here. Adding the default case means the compiler won't warn us if we forget an enum value in the switch statement.
Hugo Parente Lima
Comment 4 2013-07-11 11:43:23 PDT
(In reply to comment #3) > (From update of attachment 206399 [details]) > I'd prefer to see "switch (static_cast<Enum>(info.mode))" here. > > Adding the default case means the compiler won't warn us if we forget an enum value in the switch statement. Good point, I thought about it but avoided due to the visual ugliness :-)
Hugo Parente Lima
Comment 5 2013-07-11 11:48:48 PDT
(In reply to comment #3) > (From update of attachment 206399 [details]) > I'd prefer to see "switch (static_cast<Enum>(info.mode))" here. > > Adding the default case means the compiler won't warn us if we forget an enum value in the switch statement. btw, the enum is annonymous. struct ExpressionRangeInfo { enum { FatLineMode, FatColumnMode, FatLineAndColumnMode }; }; I'm not familiar enough with this code to suggest a name better than "FatMode" to this enum, so I would ask you a name for it. Thanks.
Geoffrey Garen
Comment 6 2013-07-11 13:22:17 PDT
> I'm not familiar enough with this code to suggest a name better than "FatMode" to this enum, so I would ask you a name for it. I'd suggest "Mode". This struct is simple enough that a terse name is OK.
Hugo Parente Lima
Comment 7 2013-07-11 13:40:09 PDT
(In reply to comment #6) > > I'm not familiar enough with this code to suggest a name better than "FatMode" to this enum, so I would ask you a name for it. > > I'd suggest "Mode". This struct is simple enough that a terse name is OK. Even with the static cast g++ still blaming about: 'line' may be used uninitialized in this function [-Werror=maybe-uninitialized] IMO better add -Werror=no-maybe-uninitialized to the build, this flag causes more headaches than advantages, until now it just generated small patches that decreased the code readability.
Note You need to log in before you can comment on or make changes to this bug.