[Bug c++/93967] New: switch on exhaustive enum gives control reaches end of non-void function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93967 Bug ID: 93967 Summary: switch on exhaustive enum gives control reaches end of non-void function Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- ``` enum class A { X, Y, Z }; int foo(A a) { switch (a) { case A::X: return 1; case A::Y: return 2; case A::Z: return 3; } } ``` `g++ input.cpp` ``` : In function 'int foo(A)': :9:1: warning: control reaches end of non-void function [-Wreturn-type] 9 | } | ^ ``` The switch is exhaustive and so there is no way that the function reaches the code path after the switch. Clang does not emit a warning. This happens on every version of gcc. Godbolt: https://cpp.godbolt.org/z/Goii_K
[Bug c++/93968] New: -Wswitch-default on exhaustive enum class gives warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93968 Bug ID: 93968 Summary: -Wswitch-default on exhaustive enum class gives warning Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- ``` enum class A { X, Y, Z }; int foo(A a) { switch (a) { case A::X: return 1; case A::Y: return 2; case A::Z: return 3; } } ``` `g++ -Wswitch-default input.cpp` ``` : In function 'int foo(A)': :4:12: warning: switch missing default case [-Wswitch-default] 4 | switch (a) { |^ ``` The switch is exhaustive and so there should no warning for a default case, but when compiling it with `-Wswitch-default` it does emit a warning. Clang does not. This happens on every version of gcc. Godbolt: https://cpp.godbolt.org/z/Goii_K
[Bug c/87365] New: Uninitiliazed variable detection
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87365 Bug ID: 87365 Summary: Uninitiliazed variable detection Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- The following snippet does not detect the unitilialized variable int foo(volatile int cond) { int a; if (cond){ a = 0; } else { while (cond) { a++; } } return a; }
[Bug c/87365] Uninitiliazed variable detection
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87365 --- Comment #1 from gcc at cookiesoft dot de --- The volatile doesn't Change anything. I guess the combination of if and Else-while confuses him
[Bug c++/99362] New: invalid unused result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99362 Bug ID: 99362 Summary: invalid unused result Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- Target: arm The following code will emit a warning on arm 32 bit compilers: ``` struct S { [[nodiscard]] S() {} }; int main() { S s; } ``` ``` : In function 'int main()': :6:7: warning: ignoring return value of 'S::S()', declared with attribute 'nodiscard' [-Wunused-result] 6 | S s; | ^ :2:19: note: declared here 2 | [[nodiscard]] S() {} | ^ :6:7: warning: ignoring return value of 'S::S()', declared with attribute 'nodiscard' [-Wunused-result] 6 | S s; | ^ :2:19: note: declared here 2 | [[nodiscard]] S() {} | ^ Compiler returned: 0 ``` ``` S s = {} ``` does not emit such warning. Does not emit a warning on x86 compiler though. Does not emit a warning on 9.x branch, seems to be a regression. Godbolt link: https://godbolt.org/z/4Kof1x
[Bug c++/99362] invalid unused result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99362 --- Comment #2 from gcc at cookiesoft dot de --- it's not my code, but a MCVE ;) I'm using [tomlplusplus](https://github.com/marzer/tomlplusplus/blob/master/toml.hpp) and there the constructor is marked as nodiscard. I may file an issue there. So, what about this issue? I guess it's still a bug?!
[Bug c/99810] New: Wrong const evaluation of 64-bit division
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810 Bug ID: 99810 Summary: Wrong const evaluation of 64-bit division Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: gcc at cookiesoft dot de Target Milestone: --- Host: x86_64 Target: arm The following code produces a different result on arm and x86_64: https://gcc.godbolt.org/z/PPvoscdWa ``` #include #include int main() { printf("%" PRId64 "\n", -621357696 / 100); } ``` ARM: -2006227456 ( 886B 6600) X86: -62135769600 ( FFF1 886B 6600) No single warning is given and I of course would like to see the x86 output, because that's the right one ;)
[Bug c/99810] Wrong const evaluation of 64-bit division
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810 --- Comment #3 from gcc at cookiesoft dot de --- I actually haven't, but yes, you're right that it will print out the correct value. I'm somewhat sorry for the noise. Is there a reason, e.g. performance, that the .word is "wrong"?
[Bug c/99810] Wrong const evaluation of 64-bit division
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810 --- Comment #5 from gcc at cookiesoft dot de --- Alright. Then again, sorry for the noise. I was hunting down a bug and thought I found it with this one... so I have to search further. Thank you everyone!