This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13500] New: reinterpret_cast allows a function to be called with too few paremeters


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]