[LLVMbugs] [Bug 13385] New: C++ parameter defaults are ignored
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jul 17 14:44:17 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13385
Bug #: 13385
Summary: C++ parameter defaults are ignored
Product: clang
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
AssignedTo: kremenek at apple.com
ReportedBy: craig+clang at trickplay.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 8916
--> http://llvm.org/bugs/attachment.cgi?id=8916
Sample C++ program showing default arguments being ignored when passed
implicitly
I have a C++ function which uses parameter defaults, eg:
MyObject * get_obj(bool destroy = false);
If I call that function explicitly with
foo = get_obj(false);
the static analyzer treats it differently than if I call it with the (same)
implicit argument:
foo = get_object();
The attached short example program shows this problem -- essentially, in my
code if "false" is passed to that function, it will return non-null or
assert(). If I explicitly pass "false", then clang correctly realizes that foo
will be non-NULL. But with the implicit argument, clang thinks foo can be NULL
and complains.
Compile sample with this:
scan-build clang++ -o test test.cpp
test.cpp:38:24: warning: Access to field 'some_contents' results in a
dereference of a null pointer (loaded from variable 'ptr')
ptr->some_contents = 42;
~~~ ^
1 warning generated.
scan-build: 1 bugs found.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list