Skip to content

Destructor without implementation targets incorrect function #310

@Southclaws

Description

@Southclaws

Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:

  • Bug Report
  • Feature Request
  • Question

What happened:

So I was messing with destructors for my pawn-errors package, eventually didn't end up using them so I removed the implementation for operator~(Error:e[], s) however I forgot that I left the forward operator~(Error:e, s); in the source file, this resulted in some very odd behaviour: when variables left scope, a seemingly random function was called with garbage data as parameters.

What you expected to happen:

I would have expected the same as if you omit any implementation, you get an error message saying "function f(x) is not implemented" however that doesn't seem to apply to operator~.

How to reproduce it (as minimally and precisely as possible):

#include <a_samp>


forward operator~(Error:right[], size);

stock Error:Error(a, what[]) {
    printf("Error called with %d '%s'", a, what);
    return Error:a;
}

main() {
    new Error:e = Error(1, "hi");
}

Side note: if you remove the assignment in main so it's just a declaration of Error:e then the server crashes once it reaches the end of main() with Stack/heap collision: insufficient stack size.

Anything else we need to know?:

I've not tried this with much other code, I did try it without the a parameter in the above repro but it still crashed. It's very strange because the signatures do not match at all, not by tag and not by parameter types.

Environment:

  • Operating System: Windows, not tested others
  • Compiler version: 3.10.7
  • How are you invoking the compiler? sampctl and command line, standard arguments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions