Re: Compiler support for forbidding certain methods from being called

2025-04-15 Thread Julian Waters via Gcc
Hi Jonathan, Thanks for the suggestion, it seems promising. I switched out the error attribute for the warning attribute at first, since they should be equivalent except warning just warns instead of erroring. This results in the link step failing if LTO is enabled for some reason though. I then c

Re: Compiler support for forbidding certain methods from being called

2025-04-14 Thread Jonathan Wakely via Gcc
On Mon, 14 Apr 2025 at 14:47, Julian Waters wrote: > > Hi Jonathan, > > Thanks for the suggestion, it seems promising. I switched out the > error attribute for the warning attribute at first, since they should > be equivalent except warning just warns instead of erroring. This > results in the lin

Re: Compiler support for forbidding certain methods from being called

2025-04-14 Thread Jonathan Wakely via Gcc
On Mon, 14 Apr 2025 at 11:53, Julian Waters wrote: > > Hi Jonathan, > > Yep, unfortunately #pragma GCC poison is far too restrictive, it > doesn't check if it is a function call to that particular banned > function, it restricts any and all use of that identifier in the code > altogether. Not only

Re: Compiler support for forbidding certain methods from being called

2025-04-14 Thread Jonathan Wakely via Gcc
On Mon, 14 Apr 2025 at 12:57, Jonathan Wakely wrote: > > On Mon, 14 Apr 2025 at 11:53, Julian Waters wrote: > > > > Hi Jonathan, > > > > Yep, unfortunately #pragma GCC poison is far too restrictive, it > > doesn't check if it is a function call to that particular banned > > function, it restricts

Compiler support for forbidding certain methods from being called

2025-04-14 Thread Basile Starynkevitch
> > > A codebase I'm working with has decided that poisoning certain > standard library functions is necessary, as it explicitly does not use > those functions unless absolutely necessary for its own reasons (This > was not my decision to make). As such, we've been looking into ways to > implemen

Re: Compiler support for forbidding certain methods from being called

2025-04-14 Thread Julian Waters via Gcc
Hi Jonathan, Yep, unfortunately #pragma GCC poison is far too restrictive, it doesn't check if it is a function call to that particular banned function, it restricts any and all use of that identifier in the code altogether. Not only does this mean you can't use overloads of a banned function, you

Re: Compiler support for forbidding certain methods from being called

2025-04-14 Thread Jonathan Wakely via Gcc
On Mon, 14 Apr 2025 at 10:11, Julian Waters via Gcc wrote: > > Hi all, > > A codebase I'm working with has decided that poisoning certain > standard library functions is necessary, as it explicitly does not use > those functions unless absolutely necessary for its own reasons (This > was not my de

Compiler support for forbidding certain methods from being called

2025-04-14 Thread Julian Waters via Gcc
Hi all, A codebase I'm working with has decided that poisoning certain standard library functions is necessary, as it explicitly does not use those functions unless absolutely necessary for its own reasons (This was not my decision to make). As such, we've been looking into ways to implement that.