testcase: t.cpp
#include <iostream>
#include <string>

using namespace std;

void func_1( )
{
  string aCvla="func1";
  throw aCvla;
}

void func_2 ()
{
  char aCvla[6];
  strcpy (aCvla, "func2");
  throw aCvla;
}

int main()
{
  try {
    func_1();
  } catch ( string &aCA ) {
    cout << aCA << endl;
  }
  try {
    func_2();
  } catch ( char * aCA ) {
    cout << aCA << endl;
  }
}



Invocations
g++ t.cpp
./a.out

expected output:
func1
func2

Actual output:
func1
<garbage>


-- 
           Summary: throw catch clause does not accept string
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alienforever at gmail dot com


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

Reply via email to