public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35069] New: Casting from a volatile type to a non-volatile type should cause a warning
@ 2008-02-04 1:33 gcc-david at tulloh dot id dot au
2008-02-04 5:19 ` [Bug c/35069] " gcc-david at tulloh dot id dot au
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gcc-david at tulloh dot id dot au @ 2008-02-04 1:33 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
2008-02-04 1:33 [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
@ 2008-02-04 5:19 ` gcc-david at tulloh dot id dot au
2008-02-04 9:11 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: gcc-david at tulloh dot id dot au @ 2008-02-04 5:19 UTC (permalink / raw)
To: gcc-bugs
--
gcc-david at tulloh dot id dot au changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
2008-02-04 1:33 [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
2008-02-04 5:19 ` [Bug c/35069] " gcc-david at tulloh dot id dot au
@ 2008-02-04 9:11 ` pinskia at gcc dot gnu dot org
2008-02-04 22:14 ` gcc-david at tulloh dot id dot au
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-04 9:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-02-04 09:11 -------
> The above cast should almost certainly have been (volatile int32_t)
The volatile here does not mean anything really so there is no lost info as it
is on a scalar type. So I am going to close this as invalid.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
2008-02-04 1:33 [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
2008-02-04 5:19 ` [Bug c/35069] " gcc-david at tulloh dot id dot au
2008-02-04 9:11 ` pinskia at gcc dot gnu dot org
@ 2008-02-04 22:14 ` gcc-david at tulloh dot id dot au
2008-02-04 22:17 ` pinskia at gcc dot gnu dot org
2008-11-14 23:56 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: gcc-david at tulloh dot id dot au @ 2008-02-04 22:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gcc-david at tulloh dot id dot au 2008-02-04 22:14 -------
Yes, I didn't provide any context. I believe that this warning should apply
any time you are working with volatile variables.
A truncated real world example (kind of, real world debugging).
volatile static uint8_t OutputBuffer[4];
int16_t main(void) {
while(1) {
*(uint16_t *)(OutputBuffer)++;
}
}
ISR(PCINT0_vect) {
implement software SPI interface, transmit OutputBuffer in reverse byte
order.
}
--
gcc-david at tulloh dot id dot au changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
2008-02-04 1:33 [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
` (2 preceding siblings ...)
2008-02-04 22:14 ` gcc-david at tulloh dot id dot au
@ 2008-02-04 22:17 ` pinskia at gcc dot gnu dot org
2008-11-14 23:56 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-04 22:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2008-02-04 22:16 -------
Anyways you are violating C aliasing rules here.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
2008-02-04 1:33 [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
` (3 preceding siblings ...)
2008-02-04 22:17 ` pinskia at gcc dot gnu dot org
@ 2008-11-14 23:56 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-14 23:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-11-14 23:55 -------
-Wcast-qual exist already and works like what you want it to work.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35069
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-11-14 23:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-04 1:33 [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
2008-02-04 5:19 ` [Bug c/35069] " gcc-david at tulloh dot id dot au
2008-02-04 9:11 ` pinskia at gcc dot gnu dot org
2008-02-04 22:14 ` gcc-david at tulloh dot id dot au
2008-02-04 22:17 ` pinskia at gcc dot gnu dot org
2008-11-14 23:56 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).