<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 --- - Clang allows a virtual member function inside a union" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23931&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=4I9_JUEHTmTRZe3etiR7kU3BA7CeOVkqoYP25VVorJo&s=d8eS8qBb3JQzr-9HIoriTdPlm1DsqgNk30EkP1D0-S0&e=">23931</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang allows a virtual member function inside a union
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andrey.vul@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>From [class.union]p2:
"A union can have member functions (including constructors and destructors),
but not virtual (10.3) functions."
The source in question compiles when a failure diagnostic is warranted.
### SOURCE: u.cc
union A {
virtual void f();
};
### INVOCATION: clang++ -std=c++11 -c -v u.cc
clang version 3.7.0 (trunk 239822)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/home/andrey/clang.trunk/bin/clang-3.7" -cc1 -triple
powerpc64le-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name u.cc -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu ppc64le -target-abi elfv2 -v -dwarf-column-info
-coverage-file /tmp/u.cc -resource-dir
/home/andrey/clang.trunk/bin/../lib/clang/3.7.0 -internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/backward
-internal-isystem /usr/local/include -internal-isystem
/home/andrey/clang.trunk/bin/../lib/clang/3.7.0/include
-internal-externc-isystem /usr/include/powerpc64le-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19
-fmessage-length 0 -mstackrealign -fno-signed-char -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -o u.o -x c++ u.cc
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target
powerpc64le-unknown-linux-gnu
ignoring nonexistent directory "/include"
ignoring duplicate directory
"/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/backward
/usr/local/include
/home/andrey/clang.trunk/bin/../lib/clang/3.7.0/include
/usr/include/powerpc64le-linux-gnu
/usr/include
End of search list.</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>