When I compile this test case with mainline c++:

struct S {};
struct T : S {};
int f(const T*) {}
void f(T*);
int main() {
  S* s(0);
  int a = f(static_cast<const T*>(s));
  int b = f(static_cast<const T*>(0));
}

I get this:

foo.cc: In function ‘int main()’:
foo.cc:7:37: error: void value not ignored as it ought to be

This seems wrong.  I'm casting the value, so it should pick up the overload
which returns an int.  Note in particular that it works when casting 0 but
fails when casting a real object.


-- 
           Summary: Incorrect function overloading with static_cast
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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

Reply via email to