Bug 108305 - FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test
Summary: FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: testsuite-fail
Depends on:
Blocks:
 
Reported: 2023-01-05 20:03 UTC by John David Anglin
Modified: 2023-08-16 10:43 UTC (History)
1 user (show)

See Also:
Host: hppa64-hp-hpux11.11
Target: hppa64-hp-hpux11.11
Build: hppa64-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed: 2023-01-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2023-01-05 20:03:13 UTC
spawn -ignore SIGHUP /home/dave/gnu/gcc/objdir64/./gcc/xg++ -shared-libgcc -B/ho
me/dave/gnu/gcc/objdir64/./gcc -nostdinc++ -L/home/dave/gnu/gcc/objdir64/hppa64-
hp-hpux11.11/libstdc++-v3/src -L/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/
libstdc++-v3/src/.libs -L/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/libstdc
++-v3/libsupc++/.libs -B/opt/gnu64/gcc/gcc-13/hppa64-hp-hpux11.11/bin/ -B/opt/gn
u64/gcc/gcc-13/hppa64-hp-hpux11.11/lib/ -isystem /opt/gnu64/gcc/gcc-13/hppa64-hp
-hpux11.11/include -isystem /opt/gnu64/gcc/gcc-13/hppa64-hp-hpux11.11/sys-includ
e -fchecking=1 -B/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/
src/.libs -fmessage-length=0 -fno-show-column -ffunction-sections -fdata-section
s -O2 -g -DLOCALEDIR="." -nostdinc++ -I/home/dave/gnu/gcc/objdir64/hppa64-hp-hpu
x11.11/libstdc++-v3/include/hppa64-hp-hpux11.11 -I/home/dave/gnu/gcc/objdir64/hp
pa64-hp-hpux11.11/libstdc++-v3/include -I/home/dave/gnu/gcc/gcc/libstdc++-v3/lib
supc++ -I/home/dave/gnu/gcc/gcc/libstdc++-v3/include/backward -I/home/dave/gnu/g
cc/gcc/libstdc++-v3/testsuite/util /home/dave/gnu/gcc/gcc/libstdc++-v3/testsuite
/27_io/basic_ofstream/open/char/noreplace.cc -include bits/stdc++.h -fdiagnostic
s-plain-output ./libtestc++.a -lm -o ./noreplace.exe
PASS: 27_io/basic_ofstream/open/char/noreplace.cc (test for excess errors)
Setting LD_LIBRARY_PATH to :/home/dave/gnu/gcc/objdir64/gcc:/home/dave/gnu/gcc/o
bjdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libatomic/.libs:/home/dave/gnu/gcc
/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libgomp/.libs:/home/dave/gnu/gcc
/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/src/.libs::/home/dave/gnu/gcc/objdi
r64/gcc:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libato
mic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libg
omp/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/src/.li
bs::/home/dave/gnu/gcc/objdir64/gcc:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11
.11/./libstdc++-v3/../libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux
11.11/./libstdc++-v3/../libgomp/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux
11.11/./libstdc++-v3/src/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/.
/libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.li
bs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/
gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir
64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-h
pux11.11/./libatomic/.libs::/home/dave/gnu/gcc/objdir64/gcc:/home/dave/gnu/gcc/o
bjdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libatomic/.libs:/home/dave/gnu/gcc
/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/../libgomp/.libs:/home/dave/gnu/gcc
/objdir64/hppa64-hp-hpux11.11/./libstdc++-v3/src/.libs:/home/dave/gnu/gcc/objdir
64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs:/home/dave/gnu/gcc/objdir64/hppa64-hp-hpux11.11/./libatomic/.libs
Execution timeout is: 300
spawn [open ...]
/home/dave/gnu/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/noreplace.cc:28: int main(): Assertion '! of.is_open()' failed.
FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

Similar fail:

/home/dave/gnu/gcc/gcc/libstdc++-v3/testsuite/27_io/basic_ofstream/open/wchar_t/
noreplace.cc:28: int main(): Assertion '! of.is_open()' failed.
FAIL: 27_io/basic_ofstream/open/wchar_t/noreplace.cc execution test
Comment 1 Jonathan Wakely 2023-01-06 09:40:42 UTC
That test expects fopen("noreplace", "wx") to fail if the file already exists.

Does this fail too?

#include <stdio.h>
#include <stddef.h>
#include <assert.h>

int main()
{
  FILE* f = fopen("noreplace", "w");
  assert(f != NULL);
  fclose(f);
  f = fopen("noreplace", "wx");
  assert(f == NULL);
}
Comment 2 Andrew Pinski 2023-01-06 09:51:15 UTC
I suspect hpux does not implement a c11 fopen but only a c99 one ..
"x" was only added for c11 .
Hpux11.11 came out in 2009 after all.
Comment 3 Jonathan Wakely 2023-01-06 11:04:30 UTC
But then wouldn't using "x" with fopen fail, return NULL, and set errno to EINVAL?

It shouldn't just ignore the "x".
Comment 4 Jonathan Wakely 2023-01-06 11:09:47 UTC
My assumption was that targets that don't support exclusive mode for fopen would fail in exactly that way, and so using std::ios::noreplace would be "conservatively unsupported". That is, it would always fail to open the file, even if it doesn't exist. That seems acceptable.

But this test FAIL suggests that the flag is just silently ignored, allowing non-exclusive access to the file. That is not acceptable, since the flag *appears* to work, but fails to establish the required invariant.

Maybe we need #ifndef __hpux__ around the declaration and all uses of std::ios::noreplace.
Comment 5 Andreas Schwab 2023-01-06 13:32:23 UTC
Ignoring unknown fopen flags is traditional behavior which is still present today, both in BSD and GNU.  Only the first character is actually checked and rejected if unknown.
Comment 6 Jonathan Wakely 2023-01-06 13:46:47 UTC
Bah.
Comment 7 Jonathan Wakely 2023-08-16 10:43:24 UTC
I think we need to make __cpp_lib_ios_noreplace depend on some new macro that is undefined by default, and defined manually in os_defines.h when we know it works.

The won't work for musl though, as it uses the generic os_defines.h