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

            Bug ID: 93666
           Summary: Dependence of optimization on use of constexpr seems
                    inappropriate
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wkaras at yahoo dot com
  Target Milestone: ---

In this example, the optimization behavior changes simply by adding the
constexpr keyword:  https://gcc.godbolt.org/z/3zWWrH

My understanding is that constexpr should not be used as a "register-esque"
hint to decide whether or not to optimize.  I think, for a constructor, it
means, if the right conditions are met, non-locals constructed with it should
be statically initialized, and are usable in compile-time const expressions.

Clang compiles this example as I would expect: 
https://gcc.godbolt.org/z/hk6Zv5

Reply via email to