[Bug c/35069] New: Casting from a volatile type to a non-volatile type should cause a warning
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
[Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
-- 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
[Bug c/35069] Casting from a volatile type to a non-volatile type should cause a warning
--- 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
[Bug c/34736] New: AVR optimiser does not keep interrupt disabled blocks small
I am compiling for an avr target and sharing variables with interrupts. To safely update the variables I am disabling interrupts but I want the interrupts to be disabled for the shortest possible period of time. The compiler shifts the instructions around slightly when optimizing, this has the effect of increasing the time that interrupts are disabled. I've attached a trivial example which demonstrates this however more complicated code has a similar result with a varying number of instructions moved into the disabled section. I'm attaching a trivial example with .c, .i (typedefs trimmed) and .s files. The gcc used is from the Debian gcc-avr package version 4.2.2-1 Compilation line was: avr-gcc -mmcu=attiny13 -Wall -Os -fsigned-char -S -c -o interrupt_disable_bug.s interrupt_disable_bug.c -- Summary: AVR optimiser does not keep interrupt disabled blocks small 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 GCC target triplet: AVR http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34736
[Bug c/34736] AVR optimiser does not keep interrupt disabled blocks small
--- Comment #1 from gcc-david at tulloh dot id dot au 2008-01-11 06:04 --- Created an attachment (id=14917) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14917&action=view) Trivial example source file -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34736
[Bug c/34736] AVR optimiser does not keep interrupt disabled blocks small
--- Comment #2 from gcc-david at tulloh dot id dot au 2008-01-11 06:05 --- Created an attachment (id=14918) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14918&action=view) Trivial example intermediate file -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34736
[Bug c/34736] AVR optimiser does not keep interrupt disabled blocks small
--- Comment #3 from gcc-david at tulloh dot id dot au 2008-01-11 06:05 --- Created an attachment (id=14919) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14919&action=view) Trivial example assembler output file -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34736