Re: [PATCH] c++: Improve printing of null pointer to data member constants [PR126599]

Jakub Jelinek <[email protected]> Tue, 4 Aug 2026 18:58:50 +0200
Newsgroups gmane.comp.gcc.patches
Message-ID <anIaSWo_TlbNyRqE@tucnak>
On Tue, Aug 04, 2026 at 06:49:31PM +0200, Jakub Jelinek wrote:
> I can reproduce it with
> struct A { int a; };
> struct __attribute__((strub ((int A::*) 0))) B {};
> though (without patch):
> ~/src/gcc/obj84/gcc/cc1plus -quiet a3.C -std=c++98
> a3.C:2:46: warning: ignoring attribute ‘strub’ because of excess arguments starting at ‘-1’ [-Wattributes]
>     2 | struct __attribute__((strub ((int A::*) 0))) B {};
>       |                                              ^
> a3.C:2:46: warning: attribute ‘strub’ does not apply to fields of aggregate type ‘B’ [-Wattributes]
> vs. (with patch):
> ~/src/gcc/obj86/gcc/cc1plus -quiet a3.C -std=c++98
> a3.C:2:46: warning: ignoring attribute ‘strub’ because of excess arguments starting at ‘(int A::*)0’ [-Wattributes]
>     2 | struct __attribute__((strub ((int A::*) 0))) B {};
>       |                                              ^
> a3.C:2:46: warning: attribute ‘strub’ does not apply to fields of aggregate type ‘B’ [-Wattributes]
> Shall I include that in the testsuite even when it just looks that
> the strub attribute diagnostics probably should be improved?

Or
struct A { int a; };
__attribute__((assume_aligned ((int A::*) 0))) int *foo ();
~/src/gcc/obj86/gcc/cc1plus -quiet a4.C -std=c++98
a4.C:2:58: warning: ‘assume_aligned’ attribute argument (int A::*)0 is not positive [-Wattributes]

	Jakub