User account creation filtered due to spam.

Bug 13500 - reinterpret_cast allows a function to be called with too few paremeters
Summary: reinterpret_cast allows a function to be called with too few paremeters
Status: RESOLVED DUPLICATE of bug 4205
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-28 04:07 UTC by Jim Apple
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Apple 2003-12-28 04:07:19 UTC
void f0(int = 5) {}
void f1(int = 2) {}
void f_(int) {}
                                                                               
                      
template<typename T>
void back_forth(T * y) {
  reinterpret_cast<T *>(reinterpret_cast<void (*)()>(y))();
}
                                                                               
                      
int main() {
  //back_forth(f_); //fails!
  back_forth(f0);
  back_forth(f1);
  back_forth(f_); //succeeds!
}

In addition, the call to f1 inside back_forth(f1) thinks the argument is 5, not 2.
Comment 1 Andrew Pinski 2003-12-28 04:12:12 UTC
This is a dup of bug 4205, the reinterpret_cast is not needed.

*** This bug has been marked as a duplicate of 4205 ***