public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set @ 2021-08-08 7:29 mohan.rajanna at ict dot nl 2021-08-08 7:37 ` [Bug c++/101817] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: mohan.rajanna at ict dot nl @ 2021-08-08 7:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 Bug ID: 101817 Summary: g++ apply optimization irrespective of -O0 flag is set Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mohan.rajanna at ict dot nl Target Milestone: --- Created attachment 51273 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51273&action=edit disassemble log captured during gdb session Hello Team, I observe g++ applies optimization even when -O0 flag is used for compiling. I am performing unit testing with CMocka setup. Due to optimization, I am unable to test stub function call to strncmp(). Please Note: Stub function call to strncmp() will work in some cases but most of the time, function calls are optimized. I am performing debug build, cmake build log with verbose argument says source file is compiled with below example. I believe in this case -O0 is applied by default. Example: std=c++14 -g -o test.c.o -c test.c Just for Information: I manually applied -O0 in CMakeLists.txt with this line set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") and below was the cmake verbose log. std=c++14 -g -O0 -o test.c.o -c test.c Please find the attachment to see disassemble log captured during gdb session. Please find below the versions used for g++, cmake, ubuntu: g++ --version g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 cmake --version cmake version 3.16.3 Ubuntu 20.04.2 LTS This is inconsistent behaviour with -O0 flag. Sometimes this flag disables the optimization but not always. Kind Regards Mohan ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/101817] g++ apply optimization irrespective of -O0 flag is set 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl @ 2021-08-08 7:37 ` pinskia at gcc dot gnu.org 2021-08-08 7:43 ` mohan.rajanna at ict dot nl ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-08 7:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Use -fno-builtins ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/101817] g++ apply optimization irrespective of -O0 flag is set 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl 2021-08-08 7:37 ` [Bug c++/101817] " pinskia at gcc dot gnu.org @ 2021-08-08 7:43 ` mohan.rajanna at ict dot nl 2021-08-13 19:38 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: mohan.rajanna at ict dot nl @ 2021-08-08 7:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 --- Comment #2 from Mohan <mohan.rajanna at ict dot nl> --- With -fno-builtins argument, it works good !! ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/101817] g++ apply optimization irrespective of -O0 flag is set 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl 2021-08-08 7:37 ` [Bug c++/101817] " pinskia at gcc dot gnu.org 2021-08-08 7:43 ` mohan.rajanna at ict dot nl @ 2021-08-13 19:38 ` pinskia at gcc dot gnu.org 2021-08-16 6:22 ` mohan.rajanna at ict dot nl 2021-08-16 10:01 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-08-13 19:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Invalid, we do some simplifications at -O0 including inlining of some builtins which includes strncmp. As I mentioned use -fno-builtins if you don't want builtins to be reconigized. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/101817] g++ apply optimization irrespective of -O0 flag is set 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl ` (2 preceding siblings ...) 2021-08-13 19:38 ` pinskia at gcc dot gnu.org @ 2021-08-16 6:22 ` mohan.rajanna at ict dot nl 2021-08-16 10:01 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: mohan.rajanna at ict dot nl @ 2021-08-16 6:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 Mohan <mohan.rajanna at ict dot nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |WORKSFORME --- Comment #4 from Mohan <mohan.rajanna at ict dot nl> --- Thank you for the information. It works good now. Please reject this bug. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/101817] g++ apply optimization irrespective of -O0 flag is set 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl ` (3 preceding siblings ...) 2021-08-16 6:22 ` mohan.rajanna at ict dot nl @ 2021-08-16 10:01 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: redi at gcc dot gnu.org @ 2021-08-16 10:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101817 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|WORKSFORME |INVALID --- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Mohan from comment #4) > It works good now. Please reject this bug. We already did, by setting the resolution to INVALID. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-16 10:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-08 7:29 [Bug c++/101817] New: g++ apply optimization irrespective of -O0 flag is set mohan.rajanna at ict dot nl 2021-08-08 7:37 ` [Bug c++/101817] " pinskia at gcc dot gnu.org 2021-08-08 7:43 ` mohan.rajanna at ict dot nl 2021-08-13 19:38 ` pinskia at gcc dot gnu.org 2021-08-16 6:22 ` mohan.rajanna at ict dot nl 2021-08-16 10:01 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).