[llvm-bugs] [Bug 37249] New: Using Wreturn-std-move: incorrect warning on some containers

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 26 00:35:17 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37249

            Bug ID: 37249
           Summary: Using Wreturn-std-move: incorrect warning on some
                    containers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andi at mozilla.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Building firefox with the latest trunk version of clang and having activated:
Wreturn-std-move we get some strange occurrences of this warning like:

>>/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)

Looking at the actual code
[https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/xpcom/threads/Scheduler.cpp#783-795]:

>>/* 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;
>>}

nsPrintfCString is declared as
[https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsPrintfCString.h?q=nsPrintfCString&redirect_type=direct#23]:

>>class nsPrintfCString : public nsAutoCStringN<16>

And going further, nsAutoCStringN<16> translates
to[https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsStringFwd.h#64]:

>>template <size_t N> using nsAutoCStringN = nsTAutoStringN<char, N>;

Structure nsTAutoStringN is an auto type, that allocates much of it's data on
stack, so in this context the warning is wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180426/90b15c99/attachment.html>


More information about the llvm-bugs mailing list