This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13500] New: reinterpret_cast allows a function to be called with too few paremeters
- From: "japple at freeshell dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Dec 2003 04:07:21 -0000
- Subject: [Bug c++/13500] New: reinterpret_cast allows a function to be called with too few paremeters
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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.
--
Summary: reinterpret_cast allows a function to be called with
too few paremeters
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: japple at freeshell dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13500