Bug 55271 - missing warning set-but-unused
Summary: missing warning set-but-unused
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-11 13:32 UTC by Dmitry G. Dyachenko
Modified: 2012-11-11 20:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry G. Dyachenko 2012-11-11 13:32:48 UTC
$ cat test.c 
void f()
{
// missing set-but-unused
    char *li = 0;
    *li = 0; // missing dereference-null ?
}
$ /usr/local/gcc_current_193387/bin/gcc -Wall -Wextra -Ofast test.c -c
$ /usr/local/gcc_current_193387/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc_current_193387/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc_current_193387/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/dimhen/src/gcc-current/configure --prefix=/usr/local/gcc_current --with-multilib-list=m64 --enable-__cxa_atexit --enable-shared --enable-checking=yes,df,fold,rtl,tree --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,lto --enable-plugin --enable-version-specific-runtime-libs --with-tune=generic
Thread model: posix
gcc version 4.8.0 20121110 (experimental) [trunk revision 193387] (GCC)
Comment 1 Andrew Pinski 2012-11-11 17:24:19 UTC
The pointer is used in *li = 0; statement.
Comment 2 Dmitry G. Dyachenko 2012-11-11 18:42:25 UTC
oh, was over-simplified example. Sorry

void f1()
{
    char ch;
    char *p = &ch;
    *p = 0;
}

Now 2 variables are 'set-but-unused'?
Comment 3 Jakub Jelinek 2012-11-11 20:24:39 UTC
No, they are both used.  ch in &ch, and p in *p.