[Bug c++/66484] Exception specification can declare a pointer to incomplete type, which is against C++ standard section 15.1

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 11 03:01:00 GMT 2015


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The relevant text is in 15.4 Exception specifications, p2:

   A type denoted in an exception-specification shall not denote a pointer or
reference to an incomplete type, other than cv void* or a pointer or reference
to a class currently being defined.

The test case below contrasts the diagnostic issued for an ordinary function to
the absence of one for the implicit specialization of the function template.

$ cat u.c && gcc -c -std=c++11 -xc++ u.c
struct S;

void f () throw (S*);

template <class T> void g () throw (T);

void foo () {
    g<S*>();
}
u.c:3:19: warning: invalid use of incomplete type ‘struct S’
 void f () throw (S*);
                   ^
u.c:1:8: warning: forward declaration of ‘struct S’
 struct S;
        ^


More information about the Gcc-bugs mailing list