<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Crash with checkDLLAttributeRedeclaration in SemaDecl.cpp (regression in 3.9)"
href="https://llvm.org/bugs/show_bug.cgi?id=31069">31069</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash with checkDLLAttributeRedeclaration in SemaDecl.cpp (regression in 3.9)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>l.joly@castsoftware.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>If you compile the following example:
#include "Zorg.h" // Non existing file
template<typename _Tp, std::size_t _Nm = 42>
struct array
{
};
class __declspec(dllimport) DBConnectivity
{
static bool myFunc(array<int> args);
};
bool
DBConnectivity::myFunc(array<int> args)
{
}
There is a crash in checkDLLAttributeRedeclaration: The dllimport attribute of
the definition is not correctly merged with the one from the declaration,but
the code currently assume that this cannot happen, and unconditionally
dereferences a pointer to the attribute in the definition.
if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
!NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
if (IsMicrosoft && IsDefinition) {
S.Diag(NewDecl->getLocation(),
diag::warn_redeclaration_without_import_attribute)
<< NewDecl;
S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
NewDecl->dropAttr<DLLImportAttr>();
NewDecl->addAttr(::new (S.Context) DLLExportAttr(
NewImportAttr->getRange(), S.Context, // Here is the crash!
NewImportAttr->getSpellingListIndex()));
} else {
For this merge to fail, we need a combination of the following elements (if you
remove one, the code compiles with no crash):
- An unresolved #include directive
- Some dllimport on the declaration but not on the definition
- The function needs to have a parameter that is the instance of a template
- This instantiation needs to have some unspecified template argument value,
picked up as the default value (if I write static bool myFunc(array<int, 42>
args); the code no longer crashes).
This bug was introduced by the following commit:
Revision: 270686
Author: dzobnin
Date: mercredi 25 mai 2016 13:32:42
Message:
[ms][dll] #26935 Defining a dllimport function should cause it to be exported
If we have some function with dllimport attribute and then we have the function
definition in the same module but without dllimport attribute we should add
dllexport attribute to this function definition.
The same should be done for variables.
Example:
struct __declspec(dllimport) C3 {
~C3();
};
C3::~C3() {;} // we should export this definition.
Patch by Andrew V. Tischenko
Differential revision: <a href="http://reviews.llvm.org/D18953">http://reviews.llvm.org/D18953</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>