https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71431

            Bug ID: 71431
           Summary: ifstream::rdbuf directory
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimaqq at gmail dot com
  Target Milestone: ---

Pardon my primitive code:

```
    auto utf8 = std::locale(std::locale(), new std::codecvt_utf8<wchar_t>);
    std::wifstream expression(argv[1]);
    if (!expression) { /* ... */ return 99; }
    expression.imbue(utf8);
    std::wstringstream buf;
    buf << expression.rdbuf();
```

This works fine for files; fails correctly for files that won't open (doesn't
exist, wrong permissions, etc).

It doesn't fail for directories though (result is same as empty file).

None of the error bits are set either.


strace shows a failed read call:
```
open(".", O_RDONLY)                     = 4
read(4, 0x10b0250, 8191)                = -1 EISDIR (Is a directory)
```

But no error is reported. That can't be right, can it?


gcc version 6.1.1 20160501 (GCC); x86_64-pc-linux-gnu

Reply via email to