c++/7176: g++ confused by friend and static member with same name

nmusatti@comm2000.it nmusatti@comm2000.it
Mon Jul 1 04:56:00 GMT 2002


>Number:         7176
>Category:       c++
>Synopsis:       g++ confused by friend and static member with same name
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 01 04:56:03 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     nmusatti@comm2000.it
>Release:        GNU C++ version 3.1 (i686-pc-cygwin)
>Organization:
>Environment:

>Description:
The following preprocessed source should compile without errors, but doesn't:

# 1 "DateTimeNS.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "DateTimeNS.cpp"
namespace Test {

template <typename Result, typename Value> inline Result convert(Value v) {
    return Result(v);
}

class DateTime {
    friend DateTime Test::convert<DateTime,long>(long);
    static long convert(const long double & v);
};

template <> inline DateTime convert<DateTime,long>(long v) {
        return DateTime();
}

long DateTime::convert(const long double & v) {
        return long(v);
}

}

The error messages are:
DateTimeNS.cpp:9: declaration of `static long int Test::DateTime::convert(const
   long double&)'
DateTimeNS.cpp:3: changes meaning of `convert' from `Result
   Test::convert(Value)'
>How-To-Repeat:
Save the attached code without the first four lines in a source
file, say a.cpp; run
g++ -c a.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list