public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-09 18:09 ` pinskia at gcc dot gnu.org
  2021-08-09 23:14 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-09 18:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, ICC and clang have the same behavior as GCC but they might be using the
same libstdc++ here and such.

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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-4@http.gcc.gnu.org/bugzilla/>
  2021-08-09 18:09 ` [Bug c++/23257] Incorrect exception-handling behavior with references pinskia at gcc dot gnu.org
@ 2021-08-09 23:14 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-09 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
LLVM's libc++abi.so gives the same result, because it's a property of the
Itanium ABI not GCC's implementation of it.

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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2008-01-20 20:47 ` mmitchel at gcc dot gnu dot org
@ 2009-08-25 13:58 ` bangerth at gmail dot com
  4 siblings, 0 replies; 8+ messages in thread
From: bangerth at gmail dot com @ 2009-08-25 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from bangerth at gmail dot com  2009-08-25 13:58 -------
Confirmed.

Nathan, is this the bug you had worked on? If so, it may be of interest to
add a link to your patch to this PR for reference.

W.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at codesourcery dot
                   |                            |com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-08-25 13:58:06
               date|                            |


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


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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2008-01-17 10:09 ` chris dot rimmer at antixlabs dot com
@ 2008-01-20 20:47 ` mmitchel at gcc dot gnu dot org
  2009-08-25 13:58 ` bangerth at gmail dot com
  4 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-01-20 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mmitchel at gcc dot gnu dot org  2008-01-20 20:13 -------
This is a known bug in the Itanium C++ ABI.  ARM noticed this; there variant of
the C++ ABI has the additional is_reference parameter precisely to correctly
handle this case.

I looked at this in some detail at one point and concluded that the only ways
we could fix it would require a binary-compatibility break with previous
releases.  Perhaps the next major libstdc++ upgrade would be a good opportunity
for that.


-- 


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


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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
  2005-10-17 15:05 ` pinskia at gcc dot gnu dot org
  2008-01-16 12:32 ` chris dot rimmer at antixlabs dot com
@ 2008-01-17 10:09 ` chris dot rimmer at antixlabs dot com
  2008-01-20 20:47 ` mmitchel at gcc dot gnu dot org
  2009-08-25 13:58 ` bangerth at gmail dot com
  4 siblings, 0 replies; 8+ messages in thread
From: chris dot rimmer at antixlabs dot com @ 2008-01-17 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from chris dot rimmer at antixlabs dot com  2008-01-17 09:52 -------
Sorry - my earlier comment was addressing the behaviour of GCC with respect to
the DR, not the program in this bug report.

The situation in the DR is where the static type of the thrown object is
'Derived*', which the standard says should not be handled by a handler for
'Base*&'.  GCC incorrectly catches the exception in this case.

The situation in the original bug report is where the static type of the thrown
object is 'Base*', so the handler should handle the exception, since 15.3
[except.handle]/3, first list item, says that a handler of type T& is a match
for an exception of type E if E and T are the same type.  (E and T are 'Base*'
in this case).

The GCC behaviour is a bug because 15.3 [except.handle]/19 says:

"When the handler declares a reference to a non-constant object, any changes to
the referenced object are changes to the temporary object initialised when the
throw-expression was executed and will have effect should that object be
rethrown."

GCC binds the reference to a different object in each handler.  We can see this
by adding:

  std::cout << "&br = " << (void *) &br << '\n';

to each handler.  When I ran this, the output was:

  &br = 0xbfb923e8
  &br = 0xbfb923ec

(gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21))


-- 


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


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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
  2005-10-17 15:05 ` pinskia at gcc dot gnu dot org
@ 2008-01-16 12:32 ` chris dot rimmer at antixlabs dot com
  2008-01-17 10:09 ` chris dot rimmer at antixlabs dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: chris dot rimmer at antixlabs dot com @ 2008-01-16 12:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from chris dot rimmer at antixlabs dot com  2008-01-16 12:08 -------
I've just encountered the same issue.  My reading of the standard says that it
is a bug.

  15.3 [except.handle] paragraph 3
  A handler is a match for an exception object of type E if
  - The handler is of type cv T or cv T& and [...]
  - the handler is of type cv T or cv T& and [...]
  - the handler is of type cv1 T* cv2 and E is a pointer type that can be
converted to the type of the handler by [...]
  [...]

Note the lack of "or cv1 T* cv2 &" in the third list item.

Interestingly, the document "The Exception Handling ABI for the ARM
Architecture"
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf)
defines (in 8.4.2 - Personality routine helper functions) a function
__cxa_type_match which takes an argument 'bool is_reference_type'.


-- 


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


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

* [Bug c++/23257] Incorrect exception-handling behavior with references
       [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
@ 2005-10-17 15:05 ` pinskia at gcc dot gnu dot org
  2008-01-16 12:32 ` chris dot rimmer at antixlabs dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-17 15:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-10-17 15:05 -------
Hmm, this looks related to DR 388.
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#388


-- 


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


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

* [Bug c++/23257] Incorrect exception-handling behavior with references
  2005-08-06  0:25 [Bug c++/23257] New: " mmitchel at gcc dot gnu dot org
@ 2005-08-06  6:09 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-06  6:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-06 06:09 -------
Hmm, ICC 8.0 produces the same result as GCC.

-- 


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


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

end of thread, other threads:[~2021-08-09 23:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-23257-4@http.gcc.gnu.org/bugzilla/>
2021-08-09 18:09 ` [Bug c++/23257] Incorrect exception-handling behavior with references pinskia at gcc dot gnu.org
2021-08-09 23:14 ` redi at gcc dot gnu.org
     [not found] <bug-23257-332@http.gcc.gnu.org/bugzilla/>
2005-10-17 15:05 ` pinskia at gcc dot gnu dot org
2008-01-16 12:32 ` chris dot rimmer at antixlabs dot com
2008-01-17 10:09 ` chris dot rimmer at antixlabs dot com
2008-01-20 20:47 ` mmitchel at gcc dot gnu dot org
2009-08-25 13:58 ` bangerth at gmail dot com
2005-08-06  0:25 [Bug c++/23257] New: " mmitchel at gcc dot gnu dot org
2005-08-06  6:09 ` [Bug c++/23257] " pinskia at gcc dot gnu dot 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).