Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Misoptimization of case with string compares #1536
Author Name: Philipp Wagner
Original Assignee: Wilson Snyder (@wsnyder)
I have (simplified) code like this:
When I compile without WITH_DEFAULT being set, everything works as expected, and I get output like this:
But if I compile with WITH_DEFAULT set, I get this output; effectively, the default label is always taken.
The same behavior can be observed if I switch from case to if statements.
Looking at the generated C code, it looks like somehow the if/case statements get optimized out when compiling with default/else branches.
Original Redmine Comment
Thanks for the good test case. What's going on is when the case statement is getting optimized it treated the different result strings as matching when they shouldn't.
Also added a boat-load of assertions to check for similar missing string cases, but nothing turned up in existing regressions.
Fixed in git towards eventual 4.020 release.