[Bug c/60837] New: initializer element is not constant: int test = (1, 2) + 1;
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60837 Bug ID: 60837 Summary: initializer element is not constant: int test = (1, 2) + 1; Product: gcc Version: unknown Status: UNCONFIRMED Severity: major Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: potrepa...@asc-ural.ru main.c -- int test = (6, 9) + 1; int main( void ) { return 0; } -- >gcc main.c main.c:1:1: error: initializer element is not constant
[Bug c/60837] initializer element is not constant: int test = (1, 2) + 1;
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60837 ilya changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #1 from ilya --- Reread C standart. 6.6 Constant expressions Constraints Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within a subexpression that is not evaluated.
[Bug c/60838] New: bugos warning: initializer element is not a constant expression: int test = (0 ? (1,0) : 0) + 1;
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60838 Bug ID: 60838 Summary: bugos warning: initializer element is not a constant expression: int test = (0 ? (1,0) : 0) + 1; Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: potrepa...@asc-ural.ru main.c: - int test = (0 ? (3, 0) : 0) + 1; int main( void ) { return 0; } - >gcc main.c main.c:1:12: warning: initializer element is not a constant expression This is work, but generate warning: #define CT_ASSERT_EXPR(ex) (0 ? ((struct { int a:((ex) ? 1 : -1); } *)0,0) : 0) #define CT_ASSERT(ex) extern char ct_assert_[ CT_ASSERT_EXPR(ex)+1 ] warning: variably modified 'ct_assert_' at file scope According C standart: 6.6 Constant expressions Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within a subexpression that is not evaluated. 6.5.15 Conditional operator The first operand is evaluated; there is a sequence point after its evaluation. The second operand is evaluated only if the first compares unequal to 0; the third operand is evaluated only if the first compares equal to 0; the result is the value of the second or third operand (whichever is evaluated), converted to the type described below.
[Bug c/60838] bugos warning: initializer element is not a constant expression: int test = (0 ? (1,0) : 0) + 1;
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60838 --- Comment #1 from ilya --- Another testcase: main.c - int test1 = (0 ? 0 : 0) + 1; int test2 = (0 ? (3, 0) : 0) + 1; int test3[(0 ? 0 : 0) + 1]; int test4[(0 ? (3, 0) : 0) + 1]; int main( void ) { return 0; } - >gcc main.c main.c:2:13: warning: initializer element is not a constant expression main.c:4:5: error: variably modified ‘test4’ at file scope Checked for: gcc version 4.5.3 (GCC) gcc version 4.7.3
[Bug c/63991] New: redundant read when write to volatile member of packed structure
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63991 Bug ID: 63991 Summary: redundant read when write to volatile member of packed structure Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: potrepa...@asc-ural.ru There is redundant read when write to volatile member of packed structure: exti.c: --- typedef struct { volatile unsigned int IMR; volatile unsigned int EMR; volatile unsigned int RTSR; volatile unsigned int FTSR; volatile unsigned int SWIER; volatile unsigned int PR; } EXTI_TypeDef; void EXTI_5_IRQHandler( EXTI_TypeDef * exti ) { exti->PR = 1 << 5; } --- make.bat: --- arm-none-eabi-gcc -mthumb -march=armv7e-m -fpack-struct -O2 -c exti.c -o exti-bug.o arm-none-eabi-gcc -mthumb -march=armv7e-m -O2 -c exti.c -o exti.o arm-none-eabi-objdump -a -S exti.o > exti.lst arm-none-eabi-objdump -a -S exti-bug.o > exti-bug.lst --- exti.lst --- exti.o: file format elf32-littlearm exti.o Disassembly of section .text: : 0:2320 movsr3, #32 2:6143 strr3, [r0, #20] 4:4770 bxlr 6:bf00 nop exti-bug.lst exti-bug.o: file format elf32-littlearm exti-bug.o Disassembly of section .text: : 0:2320 movsr3, #32 2:6942 ldrr2, [r0, #20] 4:6143 strr3, [r0, #20] 6:4770 bxlr