adonis0147 commented on PR #23190:
URL: https://github.com/apache/doris/pull/23190#issuecomment-1685572511
Maybe this issue is a bug in `GCC 12.1`. I can't reproduce this issue in GCC
with newer versions.
Although the code snippet mentioned above can not compiled by GCC-12 and
GCC-13, but the original code snippet has some subtle differences.
```c++
$ cat test.cpp
#include <iostream>
#include <vector>
void foo(const std::string& s) {
std::cout << "foo with string" << std::endl;
}
void foo(const std::vector<std::string>& v) {
std::cout << "foo with vector string" << std::endl;
}
int main(int argc, char** argv) {
foo({"123","456"});
}
```
I think the following code snippet is more similar to the original snippet.
```c++
#include <iostream>
#include <string_view>
#include <vector>
std::string_view prefix_1 = "prefix_1";
std::string_view prefix_2 = "prefix_2";
void foo(const std::string& s) {
std::cout << "foo with string" << std::endl;
}
void foo(const std::vector<std::string>& v) {
std::cout << "foo with vector string" << std::endl;
}
void test(const std::string& suffix) {
foo({prefix_1.data() + suffix, prefix_2.data() + suffix});
}
int main(int argc, char** argv) {
test("test");
return 0;
}
```
The above code snippet can be compiled by GCC-12 (12.3.0) and GCC-13
(13.1.0) in Docker environments (ubuntu:22.04 and ubuntu:23.04).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]