This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Ultra-SPARC Exception Problems


> Date: Tue, 11 Aug 1998 16:33:16 -0700
> To: egcs-bugs@cygnus.com
> From: Jim McKelvey <mckelvey@solstice.jpl.nasa.gov>

> #include <stdio.h>

> int main(void)
> {
>     try
>     {
>         throw "b";

  2.13.4  String literals                                   [lex.string]

1 A string literal is a sequence of characters (as  defined  in  2.13.2)  |
  surrounded  by double quotes, optionally beginning with the letter  L,
  as in "..." or L"...".  A string literal that does not begin with    L  |
  is  an  ordinary  string  literal, also referred to as a narrow string  |
  literal.  An ordinary string literal has type array of  n  const  char
  and  static storage duration (3.7), where  n is the size of the string
  as defined below, and is initialized with  the  given  characters.

>     catch (char * e)

You cannot catch const char * with a char *.

>     {
>         fprintf(stderr, "%s\n", e);
>     }

>     return 0;
> }


> Gives "Abort".

Right, as it should.

> But if you add a "const" to the catch, it will work.

Right, as it should.

Welcome to C++, this isn't a bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]