public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI
@ 2015-05-14 16:59 redi at gcc dot gnu.org
  2015-05-20 16:58 ` [Bug libstdc++/66145] [5/6 Regression] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-14 16:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66145
           Summary: std::ios_base::failure objects thrown from
                    libstdc++.so use old ABI
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: ABI
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: doko at gcc dot gnu.org
  Target Milestone: ---

Using the new cxx11 ABI in GCC5 (and trunk) the exception here isn't caught:

#define _GLIBCXX_USE_CXX11_ABI 1
#include <fstream>
#include <limits>

int main()
{
  std::fstream f;
  f.exceptions(std::ios::badbit);
  try {
    f.pword(std::numeric_limits<int>::max());
  } catch (const std::ios_base::failure&) {
    return 0;
  }
  throw 1;
}


terminate called after throwing an instance of 'std::ios_base::failure'
  what():  ios_base::_M_grow_words is not valid
Aborted (core dumped)

This is because src/c++11/functexcept.cc has:

// We don't want to change the type thrown by __throw_ios_failure (yet?)
#define _GLIBCXX_USE_CXX11_ABI 0

I actually planned to change it for GCC5 but missed it. If we change the ABI
used to compile functexcept.cc then the code above would fail when using the
old ABI instead.

One option to make both forms work would be to hack the EH runtime to make
handlers for std::ios_base::failure able to catch
std::ios_base::failure[abi:cxx11] objects, and vice versa, creating an object
of the other type on the fly.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/66145] [5/6 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI
  2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
@ 2015-05-20 16:58 ` redi at gcc dot gnu.org
  2015-06-01 12:02 ` hjl.tools at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-20 16:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-05-20
      Known to work|                            |4.8.4, 4.9.2
            Summary|std::ios_base::failure      |[5/6 Regression]
                   |objects thrown from         |std::ios_base::failure
                   |libstdc++.so use old ABI    |objects thrown from
                   |                            |libstdc++.so use old ABI
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Let's call this a regression, since the testcase used to catch the exception,
but now doesn't with the default build settings.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/66145] [5/6 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI
  2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
  2015-05-20 16:58 ` [Bug libstdc++/66145] [5/6 Regression] " redi at gcc dot gnu.org
@ 2015-06-01 12:02 ` hjl.tools at gmail dot com
  2015-07-23 11:11 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2015-06-01 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |costamagnagianfranco@yahoo.
                   |                            |it

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
*** Bug 66262 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/66145] [5/6 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI
  2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
  2015-05-20 16:58 ` [Bug libstdc++/66145] [5/6 Regression] " redi at gcc dot gnu.org
  2015-06-01 12:02 ` hjl.tools at gmail dot com
@ 2015-07-23 11:11 ` rguenth at gcc dot gnu.org
  2015-10-06 21:52 ` redi at gcc dot gnu.org
  2015-10-06 23:02 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-23 11:11 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
           Priority|P3                          |P2
   Target Milestone|---                         |5.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/66145] [5/6 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI
  2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-07-23 11:11 ` rguenth at gcc dot gnu.org
@ 2015-10-06 21:52 ` redi at gcc dot gnu.org
  2015-10-06 23:02 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-06 21:52 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced from testcase at  https://bugzilla.redhat.com/show_bug.cgi?id=1269290

#include <iostream>
#include <fstream>
#include <system_error>
#include <exception>


int main() {

  try {
    std::ifstream input("notafile");
    input.exceptions(std::ifstream::failbit | std::ifstream::badbit);
    input.get();
  } catch(const std::ios::failure &e) {
    std::cout << "caught a failure " << e.what()
      << '\n';
  } catch(const std::system_error &e) {
    std::cout << "caught a system_error " << e.what()
      << '\n';
  } catch(const std::runtime_error &e) {
    std::cout << "caught a runtime_error " << e.what()
      << '\n';
  } catch(const std::exception &e) {
    std::cout << "caught an exception " << e.what()
      << '\n';
  }
}

The last handler matches, but it should have matched earlier.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/66145] [5/6 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI
  2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-10-06 21:52 ` redi at gcc dot gnu.org
@ 2015-10-06 23:02 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-06 23:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> The last handler matches, but it should have matched earlier.

Doh, this is expected, because the C++03 ios::failure doesn't derive from
runtime_error.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-06 23:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 16:59 [Bug libstdc++/66145] New: std::ios_base::failure objects thrown from libstdc++.so use old ABI redi at gcc dot gnu.org
2015-05-20 16:58 ` [Bug libstdc++/66145] [5/6 Regression] " redi at gcc dot gnu.org
2015-06-01 12:02 ` hjl.tools at gmail dot com
2015-07-23 11:11 ` rguenth at gcc dot gnu.org
2015-10-06 21:52 ` redi at gcc dot gnu.org
2015-10-06 23:02 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).