From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 645 invoked by alias); 16 Sep 2011 09:32:29 -0000 Received: (qmail 632 invoked by uid 22791); 16 Sep 2011 09:32:27 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,RCVD_NUMERIC_HELO,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Sep 2011 09:32:11 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R4UmG-0006Yh-Ua for gcc-help@gcc.gnu.org; Fri, 16 Sep 2011 11:32:08 +0200 Received: from 79.161.10.130 ([79.161.10.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Sep 2011 11:32:08 +0200 Received: from david by 79.161.10.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Sep 2011 11:32:08 +0200 To: gcc-help@gcc.gnu.org From: David Brown Subject: Re: compile with gcc option -O0 or -O Date: Fri, 16 Sep 2011 09:32:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 In-Reply-To: X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00136.txt.bz2 On 16/09/2011 11:12, zou wonder wrote: > hi david: > i have tried to enable all the warning option you provided : > and here are some warnings: > As I mentioned in another post, those were warning flags /I/ use, and may not suit other people's code. In particular, you want to disable flags for warnings that don't affect the correctness of the code but lead to lots of warnings. In your case here, all the warnings have come from two flags: -Winline, and -Wpadded. -Winline warns you when the compiler does not inline a function that is otherwise marked for inlining (either explicitly, or implicitly from a class definition). Normally I would say that this indicates that something is not happening as you expect it to, perhaps due to an error in your code. But as gcc gets steadily smarter, it finds good reasons to ignore the "inline" hint. -Wpadded warns when structs have extra space added for alignment purposes. For the type of code I write, if there is extra space in the struct then I've made a mistake in the definition, so I like this warning. For many other types of code, the warnings are just annoying noise. It really depends on whether the struct has to match an existing external structure, or if it is only used within the program. So remove these two and compile again. Alternatively, begin with just "-Wall -Wextra" and see if they help you spot your mistake - most code should compile cleanly with these enabled. mvh., David > from xmmmapte.cc:3: > /work/smsc/include/stlport/stl/_ostream.h:357: warning: inlining > failed in call to ‘stlpmtx_std::basic_ostream<_CharT, _Traits>& > stlpmtx_std::endl(stlpmtx_std::basic_ostream<_CharT, _Traits>&) [with > _CharT = char, _Traits = stlpmtx_std::char_traits]’: call is > unlikely and code size would grow > /work/smsc/include/stlport/stl/_ostream.h:78: warning: called from here > In file included from xmmmapte.cc:3: > /work/smsc/include/stlport/stl/_string.h: In function ‘void > set_map_perror_from_report_cause(VARIABLE_STR*, VTASK*)’: > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2166: warning: called from here > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2166: warning: called from here > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2166: warning: called from here > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2166: warning: called from here > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2168: warning: called from here > /work/smsc/include/stlport/stl/_string.h:372: warning: inlining failed > in call to ‘stlpmtx_std::basic_string<_CharT, _Traits, > _Alloc>::~basic_string() [with _CharT = char, _Traits = > stlpmtx_std::char_traits, _Alloc = > stlpmtx_std::allocator]’: call is unlikely and code size would > grow > xmmmap.cc:2168: warning: called from here > In file included from /work/smsc/include/stlport/stl/_string_io.h:23, > > from /work/smsc/include/xmmhdrmx.h:24, > from xmmmanmx.cc:21: > /work/smsc/include/xrslimmx.h:213: warning: padding struct to align > ‘xrsIpSocketParameters_s::portNumber’ > In file included from /work/smsc/include/xsc_common_mx.h:25, > from /work/smsc/include/xscalamx.h:31, > from /work/smsc/include/xmmhdrmx.h:24, > from xmmmanmx.cc:21: > /work/smsc/include/xrsdefmx.h:54: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:59: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:89: warning: padding struct to align > ‘::smUserData’ > /work/smsc/include/xrsdefmx.h:93: warning: padding struct to align > ‘::tariffClass’ > /work/smsc/include/xrsdefmx.h:83: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:106: warning: padding struct to align > ‘::msgRef’ > /work/smsc/include/xrsdefmx.h:114: warning: padding struct to align > ‘::msgRef’ > /work/smsc/include/xrsdefmx.h:116: warning: padding struct to align > ‘::destIMSIAddr’ > /work/smsc/include/xrsdefmx.h:118: warning: padding struct to align > ‘::smUserData’ > /work/smsc/include/xrsdefmx.h:125: warning: padding struct to align > ‘::msgRef’ > /work/smsc/include/xrsdefmx.h:127: warning: padding struct to align > ‘::smUserData’ > /work/smsc/include/xrsdefmx.h:130: warning: padding struct to align > ‘::origIMSIAddr’ > /work/smsc/include/xrsdefmx.h:137: warning: padding struct to align > ‘::msgRef’ > /work/smsc/include/xrsdefmx.h:146: warning: padding struct to align > ‘::msgRef’ > /work/smsc/include/xrsdefmx.h:162: warning: padding struct to align > ‘::destIMSIAddr’ > /work/smsc/include/xrsdefmx.h:164: warning: padding struct to align > ‘::smUserData’ > /work/smsc/include/xrsdefmx.h:172: warning: padding struct to align > ‘::moSmLimit’ > /work/smsc/include/xrsdefmx.h:198: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:205: warning: padding struct to align > ‘::imsiAddr’ > /work/smsc/include/xrsdefmx.h:203: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:212: warning: padding struct to align > ‘::cause’ > /work/smsc/include/xrsdefmx.h:225: warning: padding struct size to > alignment boundary > /work/smsc/include/xrsdefmx.h:317: warning: padding struct to align ‘WPrim::req’ > > thanks > On Fri, Sep 16, 2011 at 2:31 PM, Ian Lance Taylor wrote: >> zou wonder writes: >> >>> another is what is the difference between -O0 and -O? >> >> Please reply to the mailing list, not just to me. Thanks. >> >> -O0 means no optimization. -O, which is the same as -O1, means to >> optimize the code. This is explained in the manual. >> >> >>> On Fri, Sep 16, 2011 at 2:16 PM, zou wonder wrote: >>>> Hi Ian: >>>> >>>> Acctually, i intercept the codes from our product, and there are >>>> tons of lines. >>>> >>>> so how can i provide that useful information? >> >> I don't know. What I do know is that we can't help you without seeing >> much more of the program. The tiny bit of code you showed looked fine. >> The problem was probably somewhere else. >> >> Ian >> >> >>>> On Fri, Sep 16, 2011 at 1:40 PM, Ian Lance Taylor wrote: >>>>> zou wonder writes: >>>>> >>>>>> but one weird problem is that the following codes compiled with option -O0 >>>>> >>>>> You need to show us a small complete self-contained example. >>>>> >>>>> Normally a program which works at -O0 and fails at -O1 has an >>>>> uninitialized variable somewhere. >>>>> >>>>> Ian >>>>> >>>> >> >