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

            Bug ID: 108709
           Summary: FAIL: gcc.dg/analyzer/pipe-glibc.c
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

This test fails on Windows for lack of fork.  It actually fails for not having
pipe(), also, but _pipe() does the job well enough, so that fix is a simple
#define.  It is not very apparent what the test is doing, since it doesn't get
executed and doesn't appear to have analyzer calls, but the following poor
man's solution does result in a test that executes correctly on
x86_64-redhat-linux (EL8) and x86_64-w64-mingw32 under Wine.

git diff ../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
diff --git a/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
b/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
index a8546ea9549..3b93212f56d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
@@ -30,6 +30,30 @@ write_to_pipe (int file)
   fclose (stream);
 }

+#ifdef WIN32
+// Use native _pipe with a thread on windows, as forks don't exist
+// This requires that the pipes remain open, so disable close()
+
+#include <io.h>
+#include <fcntl.h>
+#define pipe(FD) _pipe(FD, 256, O_BINARY)
+#define close(X)
+
+#include <windows.h>
+#include <process.h>
+static __cdecl void
+fake_fork (void * arg)
+{
+    int * mypipe = arg;
+    read_from_pipe (mypipe[0]);
+}
+
+#define fork() _beginthread(fake_fork, 0, mypipe)
+#define wait(X) WaitForSingleObject((void *)pid, INFINITE)
+#else
+#include <sys/wait.h>
+#endif
+
 int
 main (void)
 {
@@ -66,6 +90,7 @@ main (void)
          Close other end first. */
       close (mypipe[0]);
       write_to_pipe (mypipe[1]);
+      wait(NULL);
       return EXIT_SUCCESS;
     }
 }
  • [Bug analyzer/108709] New: FAIL:... nightstrike at gmail dot com via Gcc-bugs

Reply via email to