Bug 57258 - unused variable warning is emitted for volatile variables
Summary: unused variable warning is emitted for volatile variables
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 59801 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-05-12 20:31 UTC by Szabolcs Nagy
Modified: 2014-01-16 06:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.3.6, 4.1.2, 4.8.0
Last reconfirmed: 2013-05-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szabolcs Nagy 2013-05-12 20:31:52 UTC
unused variable warnings are incorrectly issued for
volatile variables

a volatile variable is only unused if it is not
accessed, otherwise code will be generated for
using it following the semantics of the abstract
machine

in the following example the compiler gives a
warning eventhough the generated code uses x:

$ cat example.c
void f()
{
        volatile int x = 0;
}

$ gcc-4.8 -c -Wunused-variable example.c
example.c: In function 'f':
example.c:3:15: warning: unused variable 'x' [-Wunused-variable]
  volatile int x = 0;
               ^
Comment 1 Richard Biener 2013-05-13 08:24:57 UTC
Confirmed.
Comment 2 mrs@gcc.gnu.org 2013-11-08 10:55:13 UTC
Is there a practical reason why the user would not want to remove such a variable?  We can't think of any.
Comment 3 Richard Biener 2013-11-08 12:58:23 UTC
Me neither.
Comment 4 Andrew Pinski 2014-01-16 06:33:20 UTC
*** Bug 59801 has been marked as a duplicate of this bug. ***