libstdc++: Work around modules ICE in <charconv> [PR105297]
authorPatrick Palka <ppalka@redhat.com>
Thu, 21 Apr 2022 12:34:59 +0000 (08:34 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 21 Apr 2022 12:34:59 +0000 (08:34 -0400)
This makes the initializer for __table in __from_chars_alnum_to_val
dependent in an artificial way, which works around the reported modules
testsuite ICE by preventing the compiler from evaluating the initializer
parse time.

Compared to the alternative workaround of using a non-local class type
for __table, this workaround has the advantage of slightly speeding up
compilation of <charconv>, since now the table won't get built (via
constexpr evaluation) until the integer std::from_chars overload is
instantiated.

PR c++/105297
PR c++/105322

libstdc++-v3/ChangeLog:

* include/std/charconv (__from_chars_alnum_to_val): Make
initializer for __table dependent in an artificial way.

libstdc++-v3/include/std/charconv

index f1ace40..561234c 100644 (file)
@@ -445,7 +445,9 @@ namespace __detail
        return __c - '0';
       else
        {
-         static constexpr auto __table = __from_chars_alnum_to_val_table();
+         // This initializer is deliberately made dependent in order to work
+         // around modules bug PR105322.
+         static constexpr auto __table = (_DecOnly, __from_chars_alnum_to_val_table());
          return __table.__data[__c];
        }
     }