]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix tr1/8_c_compatibility/cstdio/functions.cc regression with recent glibc
authorJakub Jelinek <jakub@redhat.com>
Fri, 13 Oct 2023 07:09:32 +0000 (09:09 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 13 Oct 2023 07:09:32 +0000 (09:09 +0200)
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).

2023-10-13  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
libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc

index 888094697512baefc13d67db6be6e9465a4668e5..db8d9dc0f67470d7a7e1202aa74638b431df29d6 100644 (file)
@@ -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;
index 9fddaf54a900f842086b62ceaf0e048bb9eb53b0..df9d7e6be980c604182933543dfbd175edc0662f 100644 (file)
@@ -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);