[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-08-16 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #7 from Jonathan Wakely  ---
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

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2023-01-06
 Status|UNCONFIRMED |NEW

--- Comment #6 from Jonathan Wakely  ---
Bah.

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread schwab--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #5 from Andreas Schwab  ---
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.

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #4 from Jonathan Wakely  ---
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.

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #3 from Jonathan Wakely  ---
But then wouldn't using "x" with fopen fail, return NULL, and set errno to
EINVAL?

It shouldn't just ignore the "x".

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #2 from Andrew Pinski  ---
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.

[Bug libstdc++/108305] FAIL: 27_io/basic_ofstream/open/char/noreplace.cc execution test

2023-01-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108305

--- Comment #1 from Jonathan Wakely  ---
That test expects fopen("noreplace", "wx") to fail if the file already exists.

Does this fail too?

#include 
#include 
#include 

int main()
{
  FILE* f = fopen("noreplace", "w");
  assert(f != NULL);
  fclose(f);
  f = fopen("noreplace", "wx");
  assert(f == NULL);
}