public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Work around modules ICE in <charconv> [PR105297]
@ 2022-04-21  3:37 Patrick Palka
  2022-04-21  8:41 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-04-21  3:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

This makes the initializer for __table in __from_chars_alnum_to_val
dependent in an artificial way, which works around the modules testsuite
ICE reported in PR105297 by preventing the initializer from getting
evaluated at 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 the <charconv> header, since now the table will not get
built (via constexpr evaluation) until one of the integer std::from_chars
overloads is actually instantiated.

Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

	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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index f1ace406017..561234cb2fc 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -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];
 	}
     }
-- 
2.36.0.rc2.10.g1ac7422e39


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Work around modules ICE in <charconv> [PR105297]
  2022-04-21  3:37 [PATCH] libstdc++: Work around modules ICE in <charconv> [PR105297] Patrick Palka
@ 2022-04-21  8:41 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2022-04-21  8:41 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc Patches, libstdc++

On Thu, 21 Apr 2022 at 04:38, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> This makes the initializer for __table in __from_chars_alnum_to_val
> dependent in an artificial way, which works around the modules testsuite
> ICE reported in PR105297 by preventing the initializer from getting
> evaluated at 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 the <charconv> header, since now the table will not get
> built (via constexpr evaluation) until one of the integer std::from_chars
> overloads is actually instantiated.
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

OK, thanks.

>
>         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 | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
> index f1ace406017..561234cb2fc 100644
> --- a/libstdc++-v3/include/std/charconv
> +++ b/libstdc++-v3/include/std/charconv
> @@ -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];
>         }
>      }
> --
> 2.36.0.rc2.10.g1ac7422e39
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-21  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21  3:37 [PATCH] libstdc++: Work around modules ICE in <charconv> [PR105297] Patrick Palka
2022-04-21  8:41 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).