C++: Add support for 'data' in the query.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-11-28 12:57:59 +00:00
parent 7b8d164692
commit 2b36ba33f0
4 changed files with 17 additions and 3 deletions

View File

@@ -5,4 +5,8 @@
| test.cpp:178:37:178:41 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
| test.cpp:181:39:181:43 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
| test.cpp:183:37:183:41 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
| test.cpp:187:31:187:35 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |
| test.cpp:187:34:187:37 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
| test.cpp:188:39:188:42 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
| test.cpp:189:44:189:47 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
| test.cpp:191:29:191:32 | call to data | The underlying string object is destroyed after the call to 'data' returns. |
| test.cpp:193:31:193:35 | call to c_str | The underlying string object is destroyed after the call to 'c_str' returns. |

View File

@@ -184,6 +184,12 @@ const char* test1(bool b1, bool b2) {
char c = std::string("hello").c_str()[0]; // GOOD
auto s6 = std::string("hello").data(); // BAD
auto s7 = b1 ? std::string("hello").data() : ""; // BAD
auto s8 = b2 ? "" : std::string("hello").data(); // BAD
char* s9;
s9 = std::string("hello").data(); // BAD
return std::string("hello").c_str(); // BAD
}