[Bug c++/93666] Dependence of optimization on use of constexpr seems inappropriate

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 11 00:22:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93666

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The source:
struct A
{
    int i{1}, j{2};
    A(int i_, int j_) : i(i_), j(j_) {}
};

A a{3,4};

struct B
{
    int i{1}, j{2};
    constexpr B(int i_, int j_) : i(i_), j(j_) {}
};

B b{3,4};
---- CUT ----
There is a big difference between B and A.  OPtimization has nothing to do with
it.  C++ says a has a dynamic constructor while b is required to be done
statically.  So GCC does not currently implement dynamic to static constructor
optimization while clang does.

There is another bug report which talks about the same.


More information about the Gcc-bugs mailing list