[llvm-bugs] [Bug 26905] New: novtable support

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 10 13:43:59 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26905

            Bug ID: 26905
           Summary: novtable support
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: adamf88 at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16019
  --> https://llvm.org/bugs/attachment.cgi?id=16019&action=edit
source code

When I tried to use Crypto++ (as static library) with Clang on Windows then I
noticed crash of my application. (without errors during compilation)
The issue was in novtable usage. If I remove novtable then everything works
well.

The example below shows how to reproduce this problem. The names are connected
to class names in Crypto++ where I found the problem.


1. Create static library with class MyClass.h / MyClass.cpp (source also in
Attahcment). Whole program optimization should be disabled.

Source code:

#pragma once

class __declspec(novtable) IteratedHashBase
{
    virtual void Init() = 0;
};

class __declspec(novtable) IteratedHashWithStaticTransform : public
IteratedHashBase
{
public:
    IteratedHashWithStaticTransform() 
    {
        this->Init();
    }

    void Init() 
    {}
};

class MD5 : public IteratedHashWithStaticTransform
{
public:
    static void InitState()    {}
};

2. Create another .exe application, and link this static library.
Source code:

#include "MyClass.h"
#include <cstdio>
int main()
{
    MD5 pY;
    int i;
    scanf("%d", &i);
}


Finally the program compiles properly.
If I use Visual Studio then everything works well.
If I use clang compiler then the program crashes.

In assembly I can see the problem in execution of this->Init(); statement.

I tested it on the last clang snapshot build r262937 (8 March 2016).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160310/eac3dd9e/attachment.html>


More information about the llvm-bugs mailing list