-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the compiling errors in gcc9 #1621
Conversation
…iling error on gcc9 Add "-Wno-stringop-overflow" option to avoid the following error: orch.cpp: In member function 'ref_resolve_status Orch::resolveFieldRefArray(type_map&, const string&, swss::KeyOpFieldsValuesTuple&, std::vector<long unsigned int>&, std::string&)': orch.cpp:609:41: error: 'strlen' argument missing terminating nul [-Werror=stringop-overflow=] 609 | object_name_list += string(&list_item_delimiter); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from orch.cpp:6: orch.h:25:12: note: referenced argument declared here 25 | const char list_item_delimiter = ','; | ^~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors According to CauldronDevelopmentLLC/cbang#29, this is an error from boost and can be suppressed by using this option Signed-off-by: Stephen Sun <stephens@nvidia.com>
It seems compiler report a true code bug. const char list_item_delimiter = ',';
object_name_list += string(&list_item_delimiter) Could you check why you feed a non zero-terminated char* to string ctor? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comment
const char list_item_delimiter = ',';
object_name_list += string(&list_item_delimiter, 1); Need to add a |
This bug should be detected by either compiler or linter. Could you help explore a general solution to detect other unfound or future occurrences, during build process? |
…the compiling error on gcc9" This reverts commit 5d32b62.
Fix it by adding a "count" argument to the ctor of string Signed-off-by: Stephen Sun <stephens@nvidia.com>
change PR name to fix gcc9 warning |
Done. |
i actually checked g++ without and with O2 optimization, and if you use & on char constant, it puts data as a single character string which is padded by zeros, and with O2 even aligned with 0x10, but it could be just good practice by gcc, it may not be guaranteed, so warning is helpful in that case |
Signed-off-by: Stephen Sun <stephens@nvidia.com>
I'm not sure whether it's related to optimization. I think the default alignment of the types whose size is less than a word length will be the word length of the machine, unless preprecess instructions like |
What I did
Fix the following error.
Signed-off-by: Stephen Sun stephens@nvidia.com
Why I did it
How I verified it
Details if related
- Which release branch to backport (provide reason below if selected)