compiler construction - Learning C++: Example of Stack Underflow in C++ -
what can simple example in c++ causes stack-underflow in case of invoking , returning method calls. familiar calling convention, i.e thiscall, stdcall , cdecl , way clean stack. in specific, wouldn't stack underflow taken care code generated compiler automatically me ?
what situations can me trouble stack-underflow ??
the way can see happening if declared function use stdcall
(or other calling convention specifies callee clean stack) , invoke function through function pointer specified cdecl
(or other calling convention stack cleaned caller). if that, called function pop stack before returning , caller pop stack leading underflow , terrible things.
in specific case of member functions, calling convention referred thiscall
, whether caller or callee cleans stack depends on compiler.
see here details of calling conventions.
Comments
Post a Comment