mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
998 stars 79 forks source link

gcc13 Internal Compiler Error #450

Closed COM8 closed 1 year ago

COM8 commented 1 year ago

Just a short heads up for all using gcc13. mpunits will not compile right now due to a potential bug in gcc:

git clone https://github.com/mpusz/units.git
cd units && mkdir build && cd build
cmake ..
cmake --build .
[ 30%] Building CXX object CMakeFiles/test_headers.dir/headers/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.cpp.o
[ 30%] Building CXX object CMakeFiles/test_headers.dir/headers/src/systems/si/include/units/isq/si/absorbed_dose.cpp.o
In file included from /home/fabian/Repos/units/src/systems/si/include/units/isq/si/force.h:33,
                 from /home/fabian/Repos/units/src/systems/si/include/units/isq/si/energy.h:32,
                 from /home/fabian/Repos/units/./src/systems/si/include/units/isq/si/absorbed_dose.h:32,
                 from /home/fabian/Repos/units/build/headers/src/systems/si/include/units/isq/si/absorbed_dose.cpp:1:
/home/fabian/Repos/units/src/systems/si/include/units/isq/si/mass.h: In substitution of ‘template<class D, class U, class Rep>  requires (Dimension<D>) && (UnitOf<U, D>) && (Representation<Rep>) class units::quantity [with D = units::isq::si::dim_mass; U = units::isq::si::gigagram; Rep = long int]’:
/home/fabian/Repos/units/src/systems/si/include/units/isq/si/mass.h:88:7:   required by substitution of ‘template<class U, class Rep>  requires (UnitOf<U, units::isq::si::dim_mass>) && (Representation<Rep>) using units::isq::si::mass = units::quantity<units::isq::si::dim_mass, U, Rep> [with U = units::isq::si::gigagram; Rep = long int]’
/home/fabian/Repos/units/src/systems/si/include/units/isq/si/mass.h:218:37:   required from here
/home/fabian/Repos/units/src/systems/si/include/units/isq/si/mass.h:88:7: internal compiler error: in iterative_hash_template_arg, at cp/pt.cc:1927
   88 | using mass = quantity<dim_mass, U, Rep>;
      |       ^~~~
Please submit a full bug report, with preprocessed source.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccG8HXcN.out file, please attach this to your bugreport.
gmake[2]: *** [CMakeFiles/test_headers.dir/build.make:1182: CMakeFiles/test_headers.dir/headers/src/systems/si/include/units/isq/si/absorbed_dose.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:575: CMakeFiles/test_headers.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

My System

# Fedora 38
gcc --version
gcc (GCC) 13.0.1 20230401 (Red Hat 13.0.1-0)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
COM8 commented 1 year ago

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

COM8 commented 1 year ago

Fixed for GCC 13.1, thanks for the bug report.

FWIW a potential workaround for this bug, which seems to work for me at least, is to remove the Magnitude constraint from to_prefix_base and to_base_scaled_unit.

mpusz commented 1 year ago

Thanks for reporting and keeping us informed!