Date: Tue, 10 Feb 2026 13:03:35 +0100
Hi Marcin,
On 2026-02-10T10:56:23+0100, Marcin Jaczewski via Std-Proposals wrote:
> niedz., 8 lut 2026 o 19:34 Arthur O'Dwyer via Std-Proposals
> <std-proposals_at_[hidden]> napisał(a):
[...]
> >> How does this use of an attribute fit the idea that attributes
> >> have optional semantics, given that the program will be ill-formed
> >> without the attribute present?
> >
> >
> > It doesn't. Nobody likes the "ignorable attribute rule." See for example
>
> False, I like how they are handled :P
> Only problem is people try sove in things that they should not.
How do you feel about this?
alx_at_devuan:~/tmp$ cat nodiscard.c++
[[nodiscard]] int f(void);
int
main(void)
{
typeof(int (void) ) *fp1;
typeof(int (void)[[nodiscard]]) *fp2;
fp1 = &f; // I would expect a diagnostic here.
fp1();
fp2 = &f;
fp2();
}
alx_at_devuan:~/tmp$ g++ -S -Wall -Wextra nodiscard.c++
nodiscard.c++: In function ‘int main()’:
nodiscard.c++:7:38: warning: ‘nodiscard’ attribute can only be applied to functions or to class or enumeration types [-Wattributes]
7 | typeof(int (void)[[nodiscard]]) *fp2;
| ^
>
> First of all, non-ignorable attributes should be explicit and ilformed
> even if the compiler does not know them even in C++11.
Agree.
> I suggested adding the prefix `!!` for one like this, this could be
> any symbol that makes C++11 reject this code and make this feature
> backward and forward compatible.
We already have non-ignorable attributes: scoped ones. This means that
[[::attr]] is already the syntax for non-ignorable attributes. It only
needs to be specified in the standard that the empty prefix is for the
standard.
> This will make a clear distinction between these two versions.
Have a lovely day!
Alex
On 2026-02-10T10:56:23+0100, Marcin Jaczewski via Std-Proposals wrote:
> niedz., 8 lut 2026 o 19:34 Arthur O'Dwyer via Std-Proposals
> <std-proposals_at_[hidden]> napisał(a):
[...]
> >> How does this use of an attribute fit the idea that attributes
> >> have optional semantics, given that the program will be ill-formed
> >> without the attribute present?
> >
> >
> > It doesn't. Nobody likes the "ignorable attribute rule." See for example
>
> False, I like how they are handled :P
> Only problem is people try sove in things that they should not.
How do you feel about this?
alx_at_devuan:~/tmp$ cat nodiscard.c++
[[nodiscard]] int f(void);
int
main(void)
{
typeof(int (void) ) *fp1;
typeof(int (void)[[nodiscard]]) *fp2;
fp1 = &f; // I would expect a diagnostic here.
fp1();
fp2 = &f;
fp2();
}
alx_at_devuan:~/tmp$ g++ -S -Wall -Wextra nodiscard.c++
nodiscard.c++: In function ‘int main()’:
nodiscard.c++:7:38: warning: ‘nodiscard’ attribute can only be applied to functions or to class or enumeration types [-Wattributes]
7 | typeof(int (void)[[nodiscard]]) *fp2;
| ^
>
> First of all, non-ignorable attributes should be explicit and ilformed
> even if the compiler does not know them even in C++11.
Agree.
> I suggested adding the prefix `!!` for one like this, this could be
> any symbol that makes C++11 reject this code and make this feature
> backward and forward compatible.
We already have non-ignorable attributes: scoped ones. This means that
[[::attr]] is already the syntax for non-ignorable attributes. It only
needs to be specified in the standard that the empty prefix is for the
standard.
> This will make a clear distinction between these two versions.
Have a lovely day!
Alex
-- <https://www.alejandro-colomar.es>
Received on 2026-02-10 12:03:42
