The manual says __FUNCTION__ is just another name for __func__ but the two
behave slightly differently (the former is not allowed in function declarations
while the latter is). __PRETTY_FUNCTION__ is also allowed but with slightly
different (and, IMO, rather unusual) effects.

I propose that __FUNCTION__ and __PRETTY_FUNCTION__ either be disallowed in
function declarations (just as __func__ is), or that they have the same meaning
as when used in the body of the function.

$ cat z.cpp && g++ z.cpp && ./a.out 
extern "C" int puts (const char*);
// void foo (const char *s = __func__) { puts (s); }
void bar (const char *s = __FUNCTION__) { puts (s); }
void baz (const char *s = __PRETTY_FUNCTION__) { puts (s); }

int main () {
    // foo ();
    bar ();
    baz ();
}

top level


-- 
           Summary: __FUNCTION__ allowed in function declaration
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


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

Reply via email to