<html>
<head>
<base href="http://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 --- - Illegal source code compiles without error when PCH is enabled"
href="http://llvm.org/bugs/show_bug.cgi?id=21304">21304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Illegal source code compiles without error when PCH is enabled
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>warren_ristow@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The test-case below, comprised of "main.cpp" and "foo.h", contains an error
which clang diagnoses well. But when compiled using PCH, no error is found.
That is, it incorrectly compiles the code that contains the error, as though
there is no error in it. The PCH-compilation incorrectly completes with
either the '-include <header_file>' style of PCH-compilation, or the
'-include-pch <pch_file>' style of PCH compilation.
________________________________________________
$ cat foo.h
///////////////////////////// "foo.h" ////////////////////////////////
#ifndef FOO_H
#define FOO_H
typedef unsigned int uint32_t;
template< class _Type >
class aTemplateClass
{
void* m_defaultObject;
public:
aTemplateClass( uint32_t size ) {}
virtual void Copy( void* dest, const void* src ) const
{
*((_Type*)dest) = *((const _Type*)src);
}
};
class aNestedClass {
aNestedClass( aNestedClass && value ) {}
};
class someClass
{
aNestedClass m_inner;
};
class someOtherClass
{
aTemplateClass <someClass > *m_tplatePtr;
someOtherClass()
{
m_tplatePtr = new aTemplateClass <someClass > ( sizeof(someClass) );
}
};
#endif
//////////////////////////////////////////////////////////////////////
$ cat main.cpp
///////////////////////////// "main.cpp" /////////////////////////////
#include "foo.h"
int main() {
aTemplateClass<int> t(10);
return 0;
}
//////////////////////////////////////////////////////////////////////
$ clang++ -std=c++11 -c main.cpp # demonstrate correct diagnosis of the error
In file included from main.cpp:2:
./foo.h:13:21: error: object of type 'someClass' cannot be assigned because its
copy assignment operator is implicitly deleted
*((_Type*)dest) = *((const _Type*)src);
^
./foo.h:10:3: note: in instantiation of member function
'aTemplateClass<someClass>::Copy' requested here
aTemplateClass( uint32_t size ) {}
^
./foo.h:28:23: note: in instantiation of member function
'aTemplateClass<someClass>::aTemplateClass' requested here
m_tplatePtr = new aTemplateClass <someClass > ( sizeof(someClass) );
^
./foo.h:21:16: note: copy assignment operator of 'someClass' is implicitly
deleted because field 'm_inner' has a deleted copy assignment operator
aNestedClass m_inner;
^
./foo.h:17:3: note: copy assignment operator is implicitly deleted because
'aNestedClass' has a user-declared move constructor
aNestedClass( aNestedClass && value ) {}
^
1 error generated.
$ clang++ -std=c++11 -x c++-header -o foo.h.pch foo.h # generate PCH file
$ clang++ -std=c++11 -c -include foo.h main.cpp # use PCH file style 1
$ clang++ -std=c++11 -c -include-pch foo.h.pch main.cpp # use PCH file style 2
$
________________________________________________
These last two commands:
$ clang++ -std=c++11 -c -include foo.h main.cpp # use PCH file style 1
$ clang++ -std=c++11 -c -include-pch foo.h.pch main.cpp # use PCH file style 2
should produce the same error as the non-PCH compilation:
$ clang++ -std=c++11 -c main.cpp # demonstrate correct diagnosis of the error
but those two "use PCH file" commands did not find the error.
Tested with:
clang version 3.6.0 (trunk 219900)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Also tried with other targets, and it appears to be target-independent.</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>