MSB6006 error "CL.exe exited with code -1073741819" caused by errors in code

0

TLDR: Both IDE and compiler missed an error in code, it only got reported by this exit code.

After a minor edit to my code regarding virtual methods, I got the error above seemingly out of nowhere. Translating the exit code to hex gives 0xc0000005, an access violation. Same problem is being solved here and here. According to those discussions, this may be caused by cl.exe being unaccessible for whatever reason, those reasons however do not apply in my case (I checked).

Another cause mentioned somewhere (I lost the link) is an error in project-specific settings. My other projects compiled with no problems, so I tried to fix that. Even when I created a new (copy of this) project, it worked. When I however moved all headers and sources to this new project, it started doing the thing again.

c++
visual-studio
compiler-errors
cl
asked on Stack Overflow Feb 13, 2021 by IWonderWhatThisAPIDoes • edited Feb 13, 2021 by IWonderWhatThisAPIDoes

1 Answer

0

I tried to go back to where the error suddenly started appearing, and I found it. I am not sure how, but this error was caused by an incorrect piece of code I had written.

One of my headers contained two classes, one of which (base) was stand-alone as it was, but the other (derived) also provided a specific wrapper for it. Both had an identical method (same name and parameter list), which is probably not the best approach, but it seemed to compile with no problems.

class Base {
    void DoStuff(void*);
    void SetValue(bool);
}

class Derived : private Base {
    void* m_ptr;
    void DoStuff() { Base::DoStuff(m_ptr); }
    void SetValue(bool b) { Base::SetValue(b); }
}

Note that I did this because of the different parameters of DoStuff, otherwise I would just inherit publicly.

Then I decided to add an interface-like (abstract) class for convenience and the error started appearing.

struct Iface {
    virtual void SetValue(bool) = 0;
}

class Base : public Iface {
    void DoStuff(void*);
    void SetValue(bool) final;
}

class Derived : private Base {
    void* m_ptr;
    void DoStuff() { Base::DoStuff(m_ptr); }
    void SetValue(bool b) { Base::SetValue(b); }
}

Do You see the obvious mistake I am making here?

After removing the final, the code compiled again. The IDE did not catch my error, likely because both Base and Derived were actually templates, and neither did the compiler, and the first thing to complain was apparently CL, which gave this not-exactly-clear exit code.


User contributions licensed under CC BY-SA 3.0