The GCC site says under "what we do not want":

"Bugs in releases or snapshots of GCC not issued by the GNU Project.
Report them to whoever provided you with the release."

So until I get enough time to build a development snapshot, I won't be
submitting this directly to the gcc folks.  I did download some of the
source for gcc 4.5.0.  My co-worker Brad and I were looking at it and
found what may be the problem.

libstdc++-v3/config/io/basic_file_stdio.cc:

  __basic_file<char>* 
  __basic_file<char>::close()
  { 
    __basic_file* __ret = static_cast<__basic_file*>(NULL);
    if (this->is_open())
      {
        int __err = 0;
        if (_M_cfile_created)
          {
            // In general, no need to zero errno in advance if checking
            // for error first. However, C89/C99 (at variance with IEEE
            // 1003.1, f.i.) do not mandate that fclose must set errno
            // upon error.
            errno = 0;
            do
              __err = fclose(_M_cfile);
            while (__err && errno == EINTR);
          }
        _M_cfile = 0;
        if (!__err)
          __ret = this;
      }
    return __ret;
  }

It appears errno should be saved in a temporary variable and restored
before the return if it did not change.

** Description changed:

  Binary package hint: gcc-4.4
- 
  
  The errno man page says:
  "errno is never set to zero by any system call or library function."
  
  However the attached test code proves otherwise.
  
  Compile with "g++ -o test test.cpp"
  Run test.  Observe that errno changes from 4 to 0.
  
  Code "passes" (ie - does not change to 0) with gcc version 3.3.3
  20040412 (Red Hat Linux 3.3.3-7)
  
  Code "fails" with:
  gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
- gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) 
- gcc version 4.3.2 (Debian 4.3.2-1.1) 
+ gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
+ gcc version 4.3.2 (Debian 4.3.2-1.1)
  
  The details:
  I'm in the process of porting some old code running in a Fedora Core 2 
environment to the Ubuntu 10.04 environment, and I came upon an issue where 
errno is getting cleared.  The attached test.cpp is a (hopefully) minimized 
test case to prove the bug.
  
  lsb_release -rd
  Description:    Ubuntu 10.04 LTS
  Release:        10.04
  
  gcc -v
  Using built-in specs.
  Target: i486-linux-gnu
  Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs 
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared 
--enable-multiarch --enable-linker-build-id --with-system-zlib 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc 
--enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic 
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu 
--target=i486-linux-gnu
  Thread model: posix
- gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 
+ gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
  
  apt-cache policy libstdc++6
  libstdc++6:
-   Installed: 4.4.3-4ubuntu5
-   Candidate: 4.4.3-4ubuntu5
-   Version table:
-  *** 4.4.3-4ubuntu5 0
-         500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
-         100 /var/lib/dpkg/status
+   Installed: 4.4.3-4ubuntu5
+   Candidate: 4.4.3-4ubuntu5
+   Version table:
+  *** 4.4.3-4ubuntu5 0
+         500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
+         100 /var/lib/dpkg/status
  
  apt-cache policy gcc
  gcc:
-   Installed: 4:4.4.3-1ubuntu1
-   Candidate: 4:4.4.3-1ubuntu1
-   Version table:
-  *** 4:4.4.3-1ubuntu1 0
-         500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
-         100 /var/lib/dpkg/status
+   Installed: 4:4.4.3-1ubuntu1
+   Candidate: 4:4.4.3-1ubuntu1
+   Version table:
+  *** 4:4.4.3-1ubuntu1 0
+         500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
+         100 /var/lib/dpkg/status
  
  Tomorrow I'll report this to gcc directly using their bugzilla.  But I
  wanted the Ubuntu team to know first, since it's their versions of gcc
  I'm using.  :)
  
  Let me know if there's anything else I can do to help,
  Chris Fester

-- 
errno cleared by ofstream close or string conversion
https://bugs.launchpad.net/bugs/598299
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to