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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems ensure_literal_type_for_constexpr_object doesn't emit any errors in
instatiations of constexpr functions:
      if (CLASS_TYPE_P (stype) && !COMPLETE_TYPE_P (complete_type (stype)))
        /* Don't complain here, we'll complain about incompleteness
           when we try to initialize the variable.  */;
      else if (!literal_type_p (type))
        {
          if (DECL_DECLARED_CONSTEXPR_P (decl))
...
          else
            {
              if (!is_instantiation_of_constexpr (current_function_decl))
                {
                  auto_diagnostic_group d;
                  error_at (DECL_SOURCE_LOCATION (decl),
                            "variable %qD of non-literal type %qT in "
                            "%<constexpr%> function", decl, type);
                  explain_non_literal_class (type);
                  decl = error_mark_node;
                }
              cp_function_chain->invalid_constexpr = true;
            }

When parsing, this isn't reached because of && !processing_template_decl, and
when it is instantiated, is_instantiation_of_constexpr (current_function_decl)
is true and so it doesn't emit the error, but just sets invalid_constexpr.

Reply via email to