[Bug c++/26433] New: Syntax error using __FUNCTION__ in catch handler

asundberg at voicemobility dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 22 22:58:00 GMT 2006


Syntax error when attempting to use the built-in macro __FUNCTION__ in the
catch handler of a try/catch block where the try/catch wraps a template class'
constructor and includes the member initializer list.

-----------------------------------------------------------------
gcc configure:

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix

-----------------------------------------------------------------
Sample code to reproduce problem:

// File: test.cpp
//
// Compile line: g++ test.cpp

int get_int()
{
    throw 1;

    return 0;
}

template <class _T> class Test
{
    public:
        Test()
        try
            : i(get_int())
        {
            i++;
        }
        catch(...)
        {
            // Syntax error caused by undefined __FUNCTION__.
            char* ptr = __FUNCTION__;
        }

    private:
        int i;
        _T t;
};

int main()
{
    try
    {
        Test<int> test;
    }
    catch(...)
    {
        return 1;
    }

    return 0;
}

-------------------------------------------------------------- 
Compilation output using command line "g++ test.cpp".

test.cpp: In constructor `Test<_T>::Test() [with _T = int]':
test.cpp:36:   instantiated from here
test.cpp:24: error: `__FUNCTION__' undeclared (first use this function)
test.cpp:24: error: (Each undeclared identifier is reported only once for each
function it appears in.)


-- 
           Summary: Syntax error using __FUNCTION__ in catch handler
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: asundberg at voicemobility dot com
 GCC build triplet: gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)
  GCC host triplet: i386-redhat-linux


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



More information about the Gcc-bugs mailing list