[Bug c/35069] New: Casting from a volatile type to a non-volatile type should cause a warning

gcc-david at tulloh dot id dot au gcc-bugzilla@gcc.gnu.org
Mon Feb 4 01:33:00 GMT 2008


Given the following code:

volatile int16_t foo;
x = (int32_t)foo;

The above cast should almost certainly have been (volatile int32_t), I see no
obvious case where someone would want to cast away the volatile attribute.

I suggest that a cast that drops a volatile attribute from a variable should
cause a warning.


(Epiphany occurred at the end of a frustrating day, was using gcc 4.2.2
targeting an AVR)


-- 
           Summary: Casting from a volatile type to a non-volatile type
                    should cause a warning
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc-david at tulloh dot id dot au


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069



More information about the Gcc-bugs mailing list