Re: Shadow data member

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 29 Sept 2021 at 21:46, Nick Savoiu via Gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
>
> Should GCC report shadowing on 'valid' for this code?
>
> Nick
>
> struct S1{    bool valid;};
> struct S2 : public S1{    bool valid;};
> struct S3 : public S2{    bool valid;};

IMHO, no, because this is name hiding, now shadowing.

The documentation for the -Wshadow warnings is clear that it refers to
local variables. For class members you can still access the base one
by qualifying it, i.e. S1::valid, S2::valid.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux