This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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++/15559] Method call and calling convention


https://sourceware.org/bugzilla/show_bug.cgi?id=15559

asmwarrior <asmwarrior at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |asmwarrior at gmail dot com

--- Comment #1 from asmwarrior <asmwarrior at gmail dot com> ---
It is very simple to reproduce this bug:
Test code: (build under GCC 4.7.x or GCC 4.8.x)

#include <string>
#include <vector>

int fff()
{
    return 3;
}

int main()
{
    std::vector<std::string> v;
    v.push_back("a");
    v.push_back("b");
    std::string abc = v[0];
    abc.c_str();
    abc.size();
    int i = v.size();
    i++;
    i = fff();

    return 0;
}


When debugging, you set a bp in the last line:
p v.size() will have such report:

GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(std::vector<std::string, std::allocator<std::string> >::size() const) will be
abandoned.
Program received signal SIGSEGV, Segmentation fault.

p fff() works OK.

This is because std::string::size() is a __thiscall call, but fff() is a
__cdecl calling convention.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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