public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc
@ 2023-10-12  7:54 Jakub Jelinek
  2023-10-12 12:05 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-10-12  7:54 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Siddhesh Poyarekar

Hi!

The following testcase started FAILing recently after the
https://sourceware.org/git/?p=glibc.git;a=commit;h=64b1a44183a3094672ed304532bedb9acc707554
glibc change which marked vfscanf with nonnull (1) attribute.
While vfwscanf hasn't been marked similarly (strangely), the patch changes
that too.  By using va_arg one hides the value of it from the compiler
(volatile keyword would do too, or making the FILE* stream a function
argument, but then it might need to be guarded by #if or something).

Tested on x86_64-linux, ok for trunk?

2023-10-12  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/tr1/8_c_compatibility/cstdio/functions.cc (test01):
	Initialize stream to va_arg(ap, FILE*) rather than 0.
	* testsuite/tr1/8_c_compatibility/cwchar/functions.cc (test01):
	Likewise.

--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc.jj	2023-01-16 23:19:06.651711546 +0100
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc	2023-10-12 09:46:28.695011763 +0200
@@ -35,7 +35,7 @@ void test01(int dummy, ...)
   char* s = 0;
   const char* cs = 0;
   const char* format = "%i";
-  FILE* stream = 0;
+  FILE* stream = va_arg(ap, FILE*);
   std::size_t n = 0;
 
   int ret;
--- libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc.jj	2023-01-16 23:19:06.651711546 +0100
+++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc	2023-10-12 09:46:19.236141897 +0200
@@ -42,7 +42,7 @@ void test01(int dummy, ...)
 #endif
 
 #if _GLIBCXX_HAVE_VFWSCANF
-  FILE* stream = 0;
+  FILE* stream = va_arg(arg, FILE*);
   const wchar_t* format1 = 0;
   int ret1;
   ret1 = std::tr1::vfwscanf(stream, format1, arg);

	Jakub


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

* Re: [PATCH] libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc
  2023-10-12  7:54 [PATCH] libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc Jakub Jelinek
@ 2023-10-12 12:05 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-10-12 12:05 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: libstdc++, gcc-patches, Siddhesh Poyarekar

[-- Attachment #1: Type: text/plain, Size: 1867 bytes --]

On Thursday, 12 October 2023, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The following testcase started FAILing recently after the
>
https://sourceware.org/git/?p=glibc.git;a=commit;h=64b1a44183a3094672ed304532bedb9acc707554
> glibc change which marked vfscanf with nonnull (1) attribute.
> While vfwscanf hasn't been marked similarly (strangely), the patch changes
> that too.  By using va_arg one hides the value of it from the compiler
> (volatile keyword would do too, or making the FILE* stream a function
> argument, but then it might need to be guarded by #if or something).
>
> Tested on x86_64-linux, ok for trunk?

OK, thanks.

>
> 2023-10-12  Jakub Jelinek  <jakub@redhat.com>
>
>         * testsuite/tr1/8_c_compatibility/cstdio/functions.cc (test01):
>         Initialize stream to va_arg(ap, FILE*) rather than 0.
>         * testsuite/tr1/8_c_compatibility/cwchar/functions.cc (test01):
>         Likewise.
>
> --- libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc.jj
2023-01-16 23:19:06.651711546 +0100
> +++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc
2023-10-12 09:46:28.695011763 +0200
> @@ -35,7 +35,7 @@ void test01(int dummy, ...)
>    char* s = 0;
>    const char* cs = 0;
>    const char* format = "%i";
> -  FILE* stream = 0;
> +  FILE* stream = va_arg(ap, FILE*);
>    std::size_t n = 0;
>
>    int ret;
> --- libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc.jj
2023-01-16 23:19:06.651711546 +0100
> +++ libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc
2023-10-12 09:46:19.236141897 +0200
> @@ -42,7 +42,7 @@ void test01(int dummy, ...)
>  #endif
>
>  #if _GLIBCXX_HAVE_VFWSCANF
> -  FILE* stream = 0;
> +  FILE* stream = va_arg(arg, FILE*);
>    const wchar_t* format1 = 0;
>    int ret1;
>    ret1 = std::tr1::vfwscanf(stream, format1, arg);
>
>         Jakub
>
>

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

end of thread, other threads:[~2023-10-12 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-12  7:54 [PATCH] libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc Jakub Jelinek
2023-10-12 12:05 ` 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).