Conversion of string literals to non-const char* is deprecated in C++03, and is ill-formed in C++11.
This patch also fixes PR16314.
Paths
| Differential D1965
C++11: Reject string literal to non-const char * conversion ClosedPublic Authored by ismailp on Oct 17 2013, 3:49 PM.
Details
Summary Conversion of string literals to non-const char* is deprecated in C++03, and is ill-formed in C++11. This patch also fixes PR16314.
Diff Detail Event TimelineComment Actions Is there any way we can continue to accept this as an extension in C++11 mode (at least in easy cases, outside of SFINAE contexts)? I'm concerned that this may break a lot of existing code.
Comment Actions We decided to limit this patch to overload resolution, addressing only PR16314. When comparing candidate functions, this conversion is considered worse than other conversions to prevent the candidate function to be the best. If this conversion happens in the best viable function, we will accept it with a warning (current behavior). Comment Actions Compared to the previous revision, this revision issues a new ExtWarn instead of the existing Warning.
Comment Actions Added new test for user defined conversion sequence.
Comment Actions Changes since last revision:
Comment Actions Sorry, forgot to Clowncopterize =( I think this is basically ready to commit, just a couple of tiny comments.
Comment Actions Added missing initializations for StandardConversionSequence::DeprecatedStringLiteralToCharPtr. Comment Actions Sorry, this is the first time I have tried arcanist (I thought arc diff would give me the diff :) ), and it seems like patch is posted before removing macros from the test case, and responding to your last feedback. Nevertheless, yes, the condition can be simplified, as long as DeprecatedStringLiteralToCharPtr is initialized. It turned out it wasn't always initialized. CHECK_BEST seems like irrelevant, and will be removed. If the rest seems ready, I will remove them before commit, instead of posting another patch. Comment Actions LGTM with the test case cleaned up to remove CHECK_BEST and the extra RUN line. Thanks!
Revision Contents
Diff 6508 include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
test/SemaCXX/cxx0x-type-convert-construct.cpp
test/SemaCXX/deprecated.cpp
test/SemaCXX/overload-0x.cpp
unittests/ASTMatchers/ASTMatchersTest.cpp
|
We spell these as ext_deprecrated_... (drop the warn_).