Re: ifstream and empty strings
From: Nikola Dudar [MSFT] (nikolad_at_online.microsoft.com)
Date: 01/07/05
- Next message: Agoston Bejo: "Redirecting cerr"
- Previous message: Arnaud Debaene: "Re: Exceptions thrown by string member functions"
- In reply to: Duane Hebert: "Re: ifstream and empty strings"
- Next in thread: Duane Hebert: "Re: ifstream and empty strings"
- Reply: Duane Hebert: "Re: ifstream and empty strings"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 6 Jan 2005 18:36:35 -0800
This has been fixed in VS2005. Now ifstream does return a null stream for
"". Also fopen("") does not assert anymore and returns null file handler and
sets errno to EINVAL to inform about invalid parameter passed to fopen().
Thanks,
Nikola
-- Nikola Dudar Visual C++ Team This posting is provided "AS IS" with no warranties, and confers no rights. "Duane Hebert" <spoo@flarn.com> wrote in message news:egXGAG$8EHA.2540@TK2MSFTNGP09.phx.gbl... > > "Tom Widmer" <tom_usenet@hotmail.com> wrote in message news:% > >> sb.open has to behave "as-if" it calls fopen, so the real question is >> whether fopen can assert here. The C standard doesn't really explicitly >> say what should happen if an invalid file name is passed to fopen, but I >> suspect that it's undefined behaviour. What makes a valid file name is >> implementation defined of course, and in Windows an empty string is >> clearly an invalid file name. > > That's most likely what's happening but I found it odd. > ifstream() should be returning a null stream and setting > the error bit when it fails to open a file. It would seem that > an invalid filename should trigger the same thing. I've > added this test in functions where I'm using it but I > found it odd. > > FWIW I'm porting stuff from BCB/VCL to > MSVC/Qt and both Borland's BCB6 and Qt seem to > handle this. > >
- Next message: Agoston Bejo: "Redirecting cerr"
- Previous message: Arnaud Debaene: "Re: Exceptions thrown by string member functions"
- In reply to: Duane Hebert: "Re: ifstream and empty strings"
- Next in thread: Duane Hebert: "Re: ifstream and empty strings"
- Reply: Duane Hebert: "Re: ifstream and empty strings"
- Messages sorted by: [ date ] [ thread ]