Re: avr-gcc-12.1.0-x64-windows new warnings ?
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <1506737405.113336.1682329382051.JavaMail.defaultUser@defaultHost> |
Hmm isnt that loading 2bytes into one ? >----Ursprungligt meddelande---- >Fr=C3=A5n : [email protected] >Datum : 2023-04-24 - 10:30 () >Till : [email protected] >=C3=84mne : Re: avr-gcc-12.1.0-x64-windows new warnings ? > >Hi, > >Am Monday, 24 April 2023, 07:46:23 CEST schrieb Senthil Kumar: >> > warning: array subscript 0 is outside array bounds of 'volatile >> > uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds] >>=20 >> Presumably from the macro expansion of PORTC? >> Can you paste the full command line? Also, can you add -E to the command >> line and share the output? > >I've frequently seen this type of error on other platforms, as well. >The warning is only generated on one of the higher optimisation levels (-O= 2),=20 >and is a result of the compiler thinking it caught an error, where there i= s=20 >none (at least for this particular use case). > >The error occurs when the linker is used to define base addresses for=20 >peripherals, but system headers provide macros for access to registers wit= h an=20 >offset via array subscription, such as: > >From system headers: >extern volatile uint8_t PERIPHERALA; >#define PERIPHERALA_SOMEREG ((&PERIPHERALA)[1]) > ><linker script:> >PERIPHERALA =3D 0x0080U (set symbol PERIPHERALA to the base address) > >I haven't found a good way yet to fix this warning, except for disabling t= he >-Warray-bounds warning for the .c file, or for the section of code where t= hose=20 >macros are invoked (#pragma). I'd be interested in a better solution. >If this error happens right on invocation of the PORTC macro, I guess, thi= s=20 >warning needs to be addressed in the avr-gcc system header themselves: > >extern volatile uint8_t PERIPHERALA[10]; /* size of peripheral addr spac= e */ >#define PERIPHERALA_SOMEREG (PERIPHERALA[1]) > >-- >Best regards, >Thilo Schulz > > > >