https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101813
Bug ID: 101813
Summary: -O3 does worse at constant folding than -O2
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: nok.raven at gmail dot com
CC: marxin at gcc dot gnu.org
Target Milestone: ---
#include <boost/optional.hpp>
#include <string>
using opts = boost::optional<std::string>;
struct foo
{
foo(opts x) : b(x), c(x) {}
opts a, b, c;
};
int main()
{
opts a;
foo bar(a);
}
at -O2 the example completely folds out, but not at -O3
https://godbolt.org/z/3n97aKKEh