<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 --- - wrong __PRETTY_FUNCTION__ found, from the wrong scope"
href="https://llvm.org/bugs/show_bug.cgi?id=30364">30364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wrong __PRETTY_FUNCTION__ found, from the wrong scope
</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>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>marmoo1024@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>For the following code produces a warning, and s is initialized from outside
the function.
#include <stdio.h>
void function() {
struct obj {
const char * str;
obj(const char * s = __PRETTY_FUNCTION__ /*or __func__*/)
: str(s) {};
};
printf ("%s\n",obj().str);
}
int main () {function();}
__func__ and __PRETTY_FUNCTION__ are supposed to be static const char *,
so they should be visible. Instead in 3.9 "top level" is printed.
If __PRETTY_FUNCTION__ is replaced with a static variable, an error is produced
instead.
#include <stdio.h>
const char other[] = "other";
void function() {
static const char other[] = "other";
struct obj {
const char * str;
obj(const char * s=other)
: str(s){};
};
printf ("%s\n",obj().str);
}
int main () {function();}</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>