Re: [PATCH v5] c++: implement [[gnu::non_owning]] [PR110358]

2024-03-04 Thread Marek Polacek
On Mon, Mar 04, 2024 at 11:00:18AM +, Jonathan Wakely wrote: > On 01/03/24 15:38 -0500, Jason Merrill wrote: > > On 3/1/24 14:24, Marek Polacek wrote: > > > +@smallexample > > > +template > > > +[[gnu::no_dangling(std::is_reference_v)]] int foo (T& t) @{ > > > > I think this function should

Re: [PATCH v5] c++: implement [[gnu::non_owning]] [PR110358]

2024-03-04 Thread Jonathan Wakely
On 01/03/24 15:38 -0500, Jason Merrill wrote: On 3/1/24 14:24, Marek Polacek wrote: +@smallexample +template +[[gnu::no_dangling(std::is_reference_v)]] int foo (T& t) @{ I think this function should return a reference. The condition in the attribute can only ever be true if you call this

Re: [PATCH v5] c++: implement [[gnu::non_owning]] [PR110358]

2024-03-01 Thread Jason Merrill
On 3/1/24 16:23, Patrick Palka wrote: Sorry for not asking this sooner, but does it matter whether we attach the attribute to the function type rather than the function declaration? I noticed e.g. nodiscard gets attached to the decl. And we document it as a function attribute despite attaching

Re: [PATCH v5] c++: implement [[gnu::non_owning]] [PR110358]

2024-03-01 Thread Patrick Palka
On Fri, 1 Mar 2024, Jason Merrill wrote: > On 3/1/24 14:24, Marek Polacek wrote: > > On Fri, Mar 01, 2024 at 01:19:40PM -0500, Jason Merrill wrote: > > > On 3/1/24 12:39, Marek Polacek wrote: > > > >@option{-Wdangling-reference} also warns about code like > > > >@smallexample > > > > @@

Re: [PATCH v5] c++: implement [[gnu::non_owning]] [PR110358]

2024-03-01 Thread Jason Merrill
On 3/1/24 14:24, Marek Polacek wrote: On Fri, Mar 01, 2024 at 01:19:40PM -0500, Jason Merrill wrote: On 3/1/24 12:39, Marek Polacek wrote: @option{-Wdangling-reference} also warns about code like @smallexample @@ -3932,6 +3935,10 @@ struct Span @{ as @code{std::span}-like; that is,