LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27087 - False positive readability-redundant-string-init for default arguments
Summary: False positive readability-redundant-string-init for default arguments
Status: RESOLVED FIXED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Etienne Bergeron
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-26 15:01 PDT by JVApen
Modified: 2016-04-07 10:58 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments
Reproduction (1.04 KB, application/x-bzip)
2016-03-26 15:01 PDT, JVApen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JVApen 2016-03-26 15:01:34 PDT
Created attachment 16101 [details]
Reproduction

#include <string>
void fn(std::string a = "");

The readability-redundant-string-init check tells me that the string 'a' has redundant string initialization. However, if I remove this, the code no longer compiles in the large picture, as I have callers of fn() without this string argument.

I've currently changed my code to: void fn(std::string a = std::string{});
This is most likely the better way of writing this code, however I still need to initialize a, hence the init is not redundant.

Note: clang-tidy has been build with rev264514.

PS: I've also noticed that this checker doesn't cover the init-list of a constructor, don't know if that is already worth logging a bug for.
Comment 1 Etienne Bergeron 2016-04-06 10:36:15 PDT
Patch here:
http://reviews.llvm.org/D18829
Comment 2 Etienne Bergeron 2016-04-07 10:58:44 PDT
fixed:
http://reviews.llvm.org/rL265671