[Bug c++/38860] New: failbit not set when it should be

aczapran at hotmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 15 20:06:00 GMT 2009


C++ pgm attempts to verify rdstate of an ofstream opened as follows:
...
ostr.open(tn, std::ios_base::out | std::ios_base::in | std::ios_base::app);
  if(ostr.rdstate() == std::ios_base::failbit)
     printf( "good\n");
  else
     printf( "bad.. should be failbit\n" );
...

gcc version info
----------------
>gcc  a.cpp -lstdc++ -save-temps -v
Using built-in specs.
Target: powerpc64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.3 --enable-ssp --disable-libssp
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.3
--enable-linux-futex --without-system-libunwind --with-cpu=power4
--enable-secureplt --with-long-double-128 --build=powerpc64-suse-linux
Thread model: posix
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mcpu=power4'
 /usr/lib64/gcc/powerpc64-suse-linux/4.3/cc1plus -E -quiet -v -D_GNU_SOURCE
-D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux
-Asystem=linux -Asystem=unix -Asystem=posix a.cpp -msecure-plt -mcpu=power4
-fpch-preprocess -o a.ii
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.3
 /usr/include/c++/4.3/powerpc64-suse-linux
 /usr/include/c++/4.3/backward
 /usr/local/include
 /usr/lib64/gcc/powerpc64-suse-linux/4.3/include
 /usr/lib64/gcc/powerpc64-suse-linux/4.3/include-fixed

/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../powerpc64-suse-linux/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mcpu=power4'
 /usr/lib64/gcc/powerpc64-suse-linux/4.3/cc1plus -fpreprocessed a.ii
-msecure-plt -quiet -dumpbase a.cpp -mcpu=power4 -auxbase a -version -o a.s
GNU C++ (SUSE Linux) version 4.3.2 [gcc-4_3-branch revision 141291]
(powerpc64-suse-linux)
        compiled by GNU C version 4.3.2 [gcc-4_3-branch revision 141291], GMP
version 4.2.3, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f744d9b01512a1796d5a77d85bde8481
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mcpu=power4'

/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../powerpc64-suse-linux/bin/as
-a64 -mpower4 -many -V -Qy -o a.o a.s
GNU assembler version 2.19 (powerpc64-suse-linux) using BFD version (GNU
Binutils; SUSE:Factory:Head) 2.19
COMPILER_PATH=/usr/lib64/gcc/powerpc64-suse-linux/4.3/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/:/usr/lib64/gcc/powerpc64-suse-linux/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/:/usr/lib64/gcc/powerpc64-suse-linux/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../powerpc64-suse-linux/bin/
LIBRARY_PATH=/usr/lib64/gcc/powerpc64-suse-linux/4.3/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../powerpc64-suse-linux/lib/:/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mcpu=power4'
 /usr/lib64/gcc/powerpc64-suse-linux/4.3/collect2 --build-id --eh-frame-hdr -V
-Qy -m elf64ppc -dynamic-linker /lib64/ld64.so.1
/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../lib64/crt1.o
/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../lib64/crti.o
/usr/lib64/gcc/powerpc64-suse-linux/4.3/crtbegin.o
-L/usr/lib64/gcc/powerpc64-suse-linux/4.3
-L/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../powerpc64-suse-linux/lib
-L/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../.. a.o -lstdc++ -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib64/gcc/powerpc64-suse-linux/4.3/crtsavres.o
/usr/lib64/gcc/powerpc64-suse-linux/4.3/crtend.o
/usr/lib64/gcc/powerpc64-suse-linux/4.3/../../../../lib64/crtn.o
GNU ld (GNU Binutils; SUSE:Factory:Head) 2.19
  Supported emulations:
   elf64ppc
   elf32ppclinux
   elf32ppc
   elf32ppcsim
a.o:(.text+0x74): warning: the use of `tmpnam' is dangerous, better use
`mkstemp'

source file... before preprocessing...
>>
#include <fstream>
#include <stdio.h>

int main(int argc, char *argv[])
{
        int adebug = 0;
        char *Filename;
        if (argc > 1 && argv[1] != 0)
                adebug = 1;
        Filename = (char*)"_2781_10Y31.cpp";

                typedef std::char_traits<char> It;
                typedef std::basic_ofstream<char, It> Ofs;
                Ofs ostr;
                const char *tn = std::tmpnam(0);
printf( "filename is:%s\n", tn );
                ostr.open(tn, std::ios_base::out | std::ios_base::in |
std::ios_base::app);
                int state = ostr.rdstate();
                if(ostr.rdstate() == std::ios_base::failbit)
                     printf( "rdstate is correct failbit set:%08x\n",
std::ios_base::failbit);
                else
                     printf( "rdstatis NOT good got:%08x expected: %08x\n",
state, std::ios_base::failbit);
                ostr.close();
                std:: remove(tn);



return 0;
}

<< end source file


-- 
           Summary: failbit not set when it should be
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aczapran at hotmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38860



More information about the Gcc-bugs mailing list