public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Yorick Rommers <yorick-rommers@hotmail.com>,
	devel@driverdev.osuosl.org, lidza.louina@gmail.com,
	driverdev-devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org
Subject: Re: gcc doesn't warn about uninitialized variable use in switch/case with -O (was: Re: [PATCH] Staging: dgnc: Using temporary value for repeated dereferences)
Date: Mon, 20 Apr 2015 05:28:13 -0700	[thread overview]
Message-ID: <1429532893.4216.36.camel@perches.com> (raw)
In-Reply-To: <1429526541.4216.18.camel@perches.com>

On Mon, 2015-04-20 at 03:42 -0700, Joe Perches wrote:
> On Mon, 2015-04-20 at 11:33 +0300, Dan Carpenter wrote:
> > You would hope that GCC would warn about the uninitialized variable but
> > it doesn't.
> 
> That's odd.  So I filed this new gcc bugzilla:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65812)
> 
> gcc 4.9.1 doesn't warn about uninitialized variable use
> declared in a switch/case statement when compiled with -O

Hey Dan/Yorick

A bit more investigation:

It's true that gcc doesn't report the uninitialized
variable for the code I showed, but that's probably not
the reason the "may be used uninitialized" warning is not
shown for the dgnc code as patched by Yorick.

The example code doesn't show the "uninitialized" warning
because gcc's dead code elimination is set by -O and the
sample code foo_2 function switch/case is eliminated.

Perhaps the warning is not shown for this dgnc patch
because your .config has CONFIG_GCOV_PROFILE_ALL set.

That enables the gcc -fprofile-arcs option which masks the
warning,  I don't know why.

Maybe see:

commit 2521f2c228ad750701ba4702484e31d876dbc386
Author: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Date:   Wed Jun 17 16:28:08 2009 -0700

    gcov: add gcov profiling infrastructure
    
    Enable the use of GCC's coverage testing tool gcov [1] with the Linux
    kernel.  gcov may be useful for:
    
     * debugging (has this code been reached at all?)
     * test improvement (how do I change my test to cover these lines?)
     * minimizing kernel configurations (do I need this option if the
       associated code is never run?)
    
    The profiling patch incorporates the following changes:
    
     * change kbuild to include profiling flags
     * provide functions needed by profiling code
     * present profiling data as files in debugfs
    
    Note that on some architectures, enabling gcc's profiling option
    "-fprofile-arcs" for the entire kernel may trigger compile/link/
    run-time problems, some of which are caused by toolchain bugs and
    others which require adjustment of architecture code.
    
    For this reason profiling the entire kernel is initially restricted
    to those architectures for which it is known to work without changes.
    This restriction can be lifted once an architecture has been tested
    and found compatible with gcc's profiling. Profiling of single files
    or directories is still available on all platforms (see config help
    text).
    
    [1] http://gcc.gnu.org/onlinedocs/gcc/Gcov.html
  


  reply	other threads:[~2015-04-20 12:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-19 19:18 [PATCH] Staging: dgnc: fixed code style issue Yorick Rommers
2015-04-19 20:34 ` Joe Perches
2015-04-19 21:58   ` [PATCH] Staging: dgnc: Using temporary value for repeated dereferences Yorick Rommers
2015-04-20  0:54     ` Joe Perches
2015-04-20  7:33       ` [PATCH] Staging: dgnc: Using a " Yorick Rommers
2015-05-03 18:50         ` Greg KH
2015-04-20  8:33       ` [PATCH] Staging: dgnc: Using " Dan Carpenter
2015-04-20 10:42         ` gcc doesn't warn about uninitialized variable use in switch/case with -O (was: Re: [PATCH] Staging: dgnc: Using temporary value for repeated dereferences) Joe Perches
2015-04-20 12:28           ` Joe Perches [this message]
2015-04-20  8:27     ` [PATCH] Staging: dgnc: Using temporary value for repeated dereferences Dan Carpenter
2015-04-20  8:13 ` [PATCH] Staging: dgnc: fixed code style issue Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429532893.4216.36.camel@perches.com \
    --to=joe@perches.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yorick-rommers@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox