You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "adonis0147 (via GitHub)" <gi...@apache.org> on 2023/08/21 03:28:31 UTC

[GitHub] [doris] adonis0147 commented on pull request #23190: [fix](compile) compile be failed with gcc12

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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org