<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 --- - Improper handling of pointers to arrays as template parameters"
href="http://llvm.org/bugs/show_bug.cgi?id=20430">20430</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Improper handling of pointers to arrays as template parameters
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>myriachan@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>The following code outputs 1 instead of 5, as if the template parameter were
decaying to "const char *" instead of being the proper "const char (*)[5]":
#include <cstdio>
template <const char (*STR)[5]>
unsigned TestBug()
{
return sizeof(*STR);
}
extern const char g_meow[5] = "meow";
int main()
{
std::printf("%u\n", TestBug<&g_meow>());
return 0;
}
This works correctly if TestBug were to take STR as a runtime parameter,
including constexpr functions evaluated at compile time. For example, the
following code prints 5:
#include <cstdio>
constexpr unsigned TestBug(const char (*STR)[5])
{
return sizeof(*STR);
}
extern const char g_meow[5] = "meow";
template <unsigned N>
struct Number
{
enum ValueType : unsigned { Value = N };
};
int main()
{
std::printf("%u\n",
static_cast<unsigned>(Number<TestBug(&g_meow)>::Value));
return 0;
}
This is all possibly related to <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Improper substitution of template arguments for pointer non-type template parameters"
href="show_bug.cgi?id=6226">bug 6226</a> or its fix, from the description of
that bug.</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>