Re: avr-gcc-12.1.0-x64-windows new warnings ?
Hi, > Hmm isnt that loading 2bytes into one ? well yes, ordinarily this would be the case. But I am specifically referring to programming close to hardware, where a register with offset 0 from the peripheral base address is configured from a linker script, and system headers defining (sub-)registers of that peripheral in terms of this base register with an array subscript. The compiler has no idea how large the address space actually is, as the declaration suggests the "array" is only a single byte long. Hence the warning. However, given that the warning complains at array offset "0", I just realised that the warning underlying the original mail: seems to be due to gcc having become stricter / buggy. As Georg-Johann wrote: >https://gcc.gnu.org/PR105523 Very interesting. I've had problems with this type of warning since gcc 9.2.0, though not necessarily on avr-gcc. -- Beste Grüße Thilo Schulz
Re: avr-gcc-12.1.0-x64-windows new warnings ?
Am 23.04.23 um 22:57 schrieb Royce Pereira: Hi, I just tried avr-gcc 12.1.0 on an old project, and got some new warning I can't explain. The code is: PORTC &= 0xFE ; //clear bit 0. and the warning is: warning: array subscript 0 is outside array bounds of 'volatile uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds] What is this warning and what array is it referring to? Thank you! -- Best Regards, -- Royce Pereira Hi, appears to be problem report PR105523 https://gcc.gnu.org/PR105523
Re: avr-gcc-12.1.0-x64-windows new warnings ?
Hmm isnt that loading 2bytes into one ? >Ursprungligt meddelande >Från : th...@tjps.eu >Datum : 2023-04-24 - 10:30 () >Till : avr-gcc-list@nongnu.org >Ämne : 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] >> >> 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 (-O2), >and is a result of the compiler thinking it caught an error, where there is >none (at least for this particular use case). > >The error occurs when the linker is used to define base addresses for >peripherals, but system headers provide macros for access to registers with an >offset via array subscription, such as: > >From system headers: >extern volatile uint8_t PERIPHERALA; >#define PERIPHERALA_SOMEREG ((&PERIPHERALA)[1]) > > >PERIPHERALA = 0x0080U (set symbol PERIPHERALA to the base address) > >I haven't found a good way yet to fix this warning, except for disabling the >-Warray-bounds warning for the .c file, or for the section of code where those >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, this >warning needs to be addressed in the avr-gcc system header themselves: > >extern volatile uint8_t PERIPHERALA[10]; /* size of peripheral addr space */ >#define PERIPHERALA_SOMEREG (PERIPHERALA[1]) > >-- >Best regards, >Thilo Schulz > > > >
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] > > 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 (-O2), and is a result of the compiler thinking it caught an error, where there is none (at least for this particular use case). The error occurs when the linker is used to define base addresses for peripherals, but system headers provide macros for access to registers with an offset via array subscription, such as: >From system headers: extern volatile uint8_t PERIPHERALA; #define PERIPHERALA_SOMEREG ((&PERIPHERALA)[1]) PERIPHERALA = 0x0080U (set symbol PERIPHERALA to the base address) I haven't found a good way yet to fix this warning, except for disabling the -Warray-bounds warning for the .c file, or for the section of code where those 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, this warning needs to be addressed in the avr-gcc system header themselves: extern volatile uint8_t PERIPHERALA[10]; /* size of peripheral addr space */ #define PERIPHERALA_SOMEREG (PERIPHERALA[1]) -- Best regards, Thilo Schulz
Re: avr-gcc-12.1.0-x64-windows new warnings ?
On Mon, Apr 24, 2023 at 2:28 AM Royce Pereira wrote: > Hi, > > I just tried avr-gcc 12.1.0 on an old project, and got some new warning I > can't explain. > > The code is: > > PORTC &= 0xFE ; //clear bit 0. > > and the warning is: > warning: array subscript 0 is outside array bounds of 'volatile > uint8_t[0]' {aka 'volatile unsigned char[]'} [-Warray-bounds] > > What is this warning and what array is it referring to? > 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? Regards Senthil > > Thank you! > > -- > Best Regards, > > -- Royce Pereira >