[LLVMbugs] [Bug 17866] New: Spurious warnings from std::u16string, std::u32string

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Nov 9 15:23:37 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=17866

            Bug ID: 17866
           Summary: Spurious warnings from std::u16string, std::u32string
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: j4cbo at dropbox.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

operator+= on std::u16string gives me the following warning buried deep in
std::u16string: "Argument to operator delete is the address of a local stack
variable, which is not memory allocated by 'new'"

Here's a simple test case, and the result of running it with the checker-275
bundle:

$ cat test.cpp 
#include <string>
void test() {
    std::u16string s;
    s += 'a';
}

$ ~/src/checker-275/scan-build clang++ -c test.cpp -std=c++11 -stdlib=libc++ \
 
'-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include'
-o test
scan-build: Using '/Users/j4cbo/src/checker-275/bin/clang' for static analysis
In file included from test.cpp:1:
In file included from
/Users/j4cbo/src/checker-275/bin/../lib/c++/v1/string:434:
In file included from
/Users/j4cbo/src/checker-275/bin/../lib/c++/v1/algorithm:594:
/Users/j4cbo/src/checker-275/bin/../lib/c++/v1/memory:1676:10: warning:
Argument to operator delete is the address of a local stack variable, which is
not memory allocated by 'new'
        {::operator delete((void*)__p);}
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: Removing directory
'/var/folders/gp/2n2s5sbn54vgg6vs4rsmqpynyr_mb4/T/scan-build-2013-11-09-12'
because it contains no reports.
scan-build: No bugs found.

(The built-in checker in XCode 5 gives the same warning, with much better
output about the intermediate call path, but that's a lot harder to paste into
a bug report...)

std::u32string causes the same error, but std::string does not.

-- 
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/20131109/92c1fd47/attachment.html>


More information about the llvm-bugs mailing list