Skip to content

Clang fails to parse mp_units #170856

@HazardyKnusperkeks

Description

@HazardyKnusperkeks

Hi,

since e9972de (#161671) clang isn't able to parse mp_units anymore as shown here: https://godbolt.org/z/4seG47hYK

In file included from <source>:1:
In file included from /opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:30:
In file included from /opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/construction_helpers.h:26:
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/quantity_point.h:144:25: error: deduced type 'struct absolute_zero' does not satisfy 'PointOriginFor<get_quantity_spec(mp_units::si::milli_<mp_units::si::kelvin>{})>'
  144 | [[nodiscard]] consteval PointOriginFor<get_quantity_spec(R{})> auto default_point_origin(R)
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/construction_helpers.h:52:79: note: in instantiation of function template specialization 'mp_units::default_point_origin<mp_units::si::milli_<mp_units::si::kelvin>>' requested here
   52 |   [[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION_WORKAROUND(R{}), default_point_origin(R{}), Rep>
      |                                                                               ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/construction_helpers.h:65:57: note: in instantiation of template class 'mp_units::absolute_<mp_units::si::milli_<mp_units::si::kelvin>>' requested here
   65 | constexpr absolute_<MP_UNITS_REMOVE_CONST(decltype(R))> absolute{};
      |                                                         ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:81:65: note: in instantiation of variable template specialization 'mp_units::absolute' requested here
   81 | inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
      |                                                                 ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/quantity_point_concepts.h:76:44: note: because 'QuantitySpecOf<decltype(kind_of_<decltype(struct thermodynamic_temperature{{{{}}}})>{{{{}}}}), struct absolute_zero::_quantity_spec_>' evaluated to false
   76 | concept PointOriginFor = PointOrigin<T> && QuantitySpecOf<MP_UNITS_REMOVE_CONST(decltype(QS)), T::_quantity_spec_>;
      |                                            ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/quantity_spec_concepts.h:141:22: note: because 'decltype(struct thermodynamic_temperature{{{{}}}})' (aka 'struct thermodynamic_temperature') does not satisfy 'QuantitySpec'
  141 |   QuantitySpec<T> && QuantitySpec<MP_UNITS_REMOVE_CONST(decltype(QS))> && detail::QuantitySpecConvertibleTo<T{}, QS> &&
      |                      ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/framework/quantity_spec_concepts.h:40:24: note: because 'mp_units::isq::thermodynamic_temperature &' does not satisfy 'SymbolicConstant'
   40 | concept QuantitySpec = detail::SymbolicConstant<T> && std::derived_from<T, detail::quantity_spec_interface_base>;
      |                        ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/ext/type_traits.h:199:28: note: because 'std::is_empty_v<mp_units::isq::thermodynamic_temperature &>' evaluated to false
  199 | concept SymbolicConstant = std::is_empty_v<T> && std::is_final_v<T>;
      |                            ^
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/ext/type_traits.h:199:28: note: 'mp_units::isq::thermodynamic_temperature &' is not empty
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/core/include/mp-units/ext/type_traits.h:199:28: note: because it is a reference type
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/isq/base_quantities.h:53:15: note: 'thermodynamic_temperature' defined here
   53 | QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature);
      |               ^
In file included from <source>:1:
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:81:65: error: type 'const absolute_<decltype(milli_<decltype(struct kelvin{{{}}})>{{{{}, {}}}})>' (aka 'const absolute_<milli_<struct kelvin>>') does not provide a call operator
   81 | inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
      |                                                                 ^~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:81:102: error: constexpr variable 'ice_point' must be initialized by a constant expression
   81 | inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
      |                                                                                                      ^~~~~~~~~
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:82:23: error: constexpr variable 'zeroth_degree_Celsius' must be initialized by a constant expression
   82 | inline constexpr auto zeroth_degree_Celsius = ice_point;
      |                       ^                       ~~~~~~~~~
/opt/compiler-explorer/libs/mp-units/v2.4.0/src/systems/include/mp-units/systems/si/units.h:83:95: error: non-type template argument is not a constant expression
   83 | inline constexpr struct degree_Celsius final : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
      |                                                                                             ^~~~~~~~~~~~~~~~~~~~~
5 errors generated.
Compiler returned: 1

CC @cor3ntin

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsneeds-reductionLarge reproducer that should be reduced into a simpler formrejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions