public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/15745] exception specification incorrectly changes the type of the exception thrown
Date: Tue, 01 Jun 2004 15:28:00 -0000	[thread overview]
Message-ID: <20040601152759.25428.qmail@sourceware.org> (raw)
In-Reply-To: <20040531075856.15745.wsf@fultondesigns.co.uk>


------- Additional Comments From bangerth at dealii dot org  2004-06-01 15:27 -------
Confirmed. Here's a small testcase: 
------------------- 
typedef int IntArray[10]; 
IntArray i; 
 
void test_array() 
#ifdef TEST 
  throw (IntArray) 
#endif 
{ throw i; } 
 
 
int main () { 
    try { 
        test_array(); 
    } catch (IntArray) {} 
} 
------------------ 
 
We get 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc ; ./a.out  
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc -DTEST ; ./a.out  
terminate called after throwing an instance of 'int*' 
Aborted 
 
The point is that if we throw an exception that violates the exception 
specification, then it is converted into an unspec exception and we 
abort. However, since we can catch the exception that we throw in the  
main function if there is no exception specification on the function 
body, it seems as if the exception thrown is really of type IntArray 
and shouldn't violate the exception specification. I agree that this 
is confusing and looks like a bug in gcc associated with decaying 
arrays to pointers, though I'd like to solicit a second opinion on 
this. 
 
We get the same results for all gcc versions from 2.95 to mainline. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to fail|                            |2.95.3 3.3.1 3.0.4 3.4.0
                   |                            |3.5.0


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


  parent reply	other threads:[~2004-06-01 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-31 22:08 [Bug c++/15745] New: " wsf at fultondesigns dot co dot uk
2004-05-31 22:26 ` [Bug c++/15745] " pinskia at gcc dot gnu dot org
2004-06-01 15:28 ` bangerth at dealii dot org [this message]
2004-06-26 20:22 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15745-8173@http.gcc.gnu.org/bugzilla/>
2007-09-06  3:34 ` jason at gcc dot gnu dot org
2007-10-01 20:53 ` jason at gcc dot gnu dot org
2008-11-18 18:52 ` jason at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040601152759.25428.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).