<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Using Wreturn-std-move: incorrect warning on some containers"
href="https://bugs.llvm.org/show_bug.cgi?id=37249">37249</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Using Wreturn-std-move: incorrect warning on some containers
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>andi@mozilla.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Building firefox with the latest trunk version of clang and having activated:
Wreturn-std-move we get some strange occurrences of this warning like:
<span class="quote">>>/var/lib/jenkins/workspace/firefox-clang-last/xpcom/threads/Scheduler.cpp:793:10: error: local variable 'result' will be copied despite being returned by name [-Werror,-Wreturn-std-move]
>> return result;
>> ^~~~~~
>>/var/lib/jenkins/workspace/firefox-clang-last/xpcom/threads/Scheduler.cpp:793:10: note: call 'std::move' explicitly to avoid copying
>> return result;
>> ^~~~~~
>> std::move(result)</span >
Looking at the actual code
[<a href="https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/xpcom/threads/Scheduler.cpp#783-795">https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/xpcom/threads/Scheduler.cpp#783-795</a>]:
<span class="quote">>>/* static */ nsCString
>>Scheduler::GetPrefs()
>>{
>> MOZ_ASSERT(XRE_IsParentProcess());
>> nsPrintfCString result("%d%d%d%d,%d",
>> Preferences::GetBool("dom.ipc.scheduler",
>> SchedulerImpl::sPrefScheduler),
>> Preferences::GetBool("dom.ipc.scheduler.chaoticScheduling",
>> SchedulerImpl::sPrefChaoticScheduling),
>> Preferences::GetBool("dom.ipc.scheduler.preemption",
>> SchedulerImpl::sPrefPreemption),
>> Preferences::GetBool("dom.ipc.scheduler.useMultipleQueues",
>> SchedulerImpl::sPrefUseMultipleQueues),
>> Preferences::GetInt("dom.ipc.scheduler.threadCount",
>> SchedulerImpl::sPrefThreadCount));
>>
>> return result;
>>}</span >
nsPrintfCString is declared as
[<a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsPrintfCString.h?q=nsPrintfCString&redirect_type=direct#23">https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsPrintfCString.h?q=nsPrintfCString&redirect_type=direct#23</a>]:
<span class="quote">>>class nsPrintfCString : public nsAutoCStringN<16></span >
And going further, nsAutoCStringN<16> translates
to[<a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsStringFwd.h#64">https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsStringFwd.h#64</a>]:
<span class="quote">>>template <size_t N> using nsAutoCStringN = nsTAutoStringN<char, N>;</span >
Structure nsTAutoStringN is an auto type, that allocates much of it's data on
stack, so in this context the warning is wrong.</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>