Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unexpected std::io_base::failure exception [duplicate]

Tags:

c++

gcc

redhat

Take this simple program:

#include <fstream>
int main()
{
    std::ifstream in(".");
    int x;
    if (in)
        in >> x;
}

on Redhat 6, gcc 4.4.7 this runs without error

on Ubuntu 14.04 LTS , gcc 4.8.2 this runs without error

on Redhat 7, gcc 4.8.2 I get:

terminate called after throwing an instance of 'std::ios_base::failure'
  what(): basic_filebuf::underflow error reading the file
Aborted (cored dumped)

I think this is related to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984

However, then I don't understand why it works on Ubuntu.

Ideas?

like image 312
user109078 Avatar asked Oct 31 '22 09:10

user109078


1 Answers

The difference isn't the compiler, the difference is the C++ library. One of them has a buggy version of libstdc++, and the other has a working version of either libstdc++ or libc++ or another version.

like image 152
Mooing Duck Avatar answered Nov 04 '22 11:11

Mooing Duck