Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum / class in different unnamed namespaces cause Error opening binary #16

Open
floriankirsch opened this issue Jan 14, 2023 · 0 comments

Comments

@floriankirsch
Copy link

I have found a bug in Sizebench (the version downloaded from the Microsoft AppStore, I did not try to compile a version from source). The bug happens when compiling an executable or dll with VC2017, when in one translation unit an unnamed namespace exists with a virtual class, and in another translation unit an unnamed namespace with an enum with the same name. The following is a minimal example. If you rename NameClash in either file to something different, the problem no longer occurs.

-------- virtualstruct.cpp --------

namespace
{
    struct NameClash
    {
        virtual ~NameClash() = default;
    };
    NameClash instance;
}

-------- main.cpp --------

namespace
{
    enum NameClash { FOO };
}

int main(int argc, char ** argv)
{
    NameClash t = NameClash(argc);
    if (t == FOO)
        return 1;
    else
        return 0;
}

When you compile this with Visual Studio 2017, and open the resulting executable with Sizebench, you get a dialog with an error message "Error opening binary! - There was an error opening this binary or PDB", following by a link to some log, and a call stack.

I have found out that this problem does not occur when compiling the same files with Visual Studio 2022.

I'll try to attach a screenshot, the content of the log file, and a zip file with the project file, which can be used with Visual Studio 2017 to compile and reproduce the bug.

sizebencherror

tmpAD61.tmp.sizebenchlog.txt

sizebenchbug.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant