ojhunt wrote:

> @ojhunt
> 
> How do you define the concept of 'dangerous' code? We're writing C++, and 
> every piece of it could be seen as unsafe, memory leak, UAF, etc.
> 
> > I had assumed that there was a real memory-usage related reason for this 
> > change.
> 
> Yes this is introduced in #192080, and we reviewers had expressed this 
> concern but the author didn't take the right approach.
> 
> In general when we want to fix a UAF bug, it's never wise/correct to convert 
> the bug to a memory leak issue. We don't want people or AI follow this 
> pattern, definitely.

In this case we're replacing the safest option: allocating on the heap, with an 
unsafe option: passing a reference to a stack allocation.

How are people meant to know from the interface to a class whether or not it is 
safe to pass a temporary object? vs when it is not? vs when a cleanup function 
needs to be called?

Meanwhile we are saying that the code base must contain "good patterns" for a 
code generator to follow. Do we think that what is being done in this case is a 
good pattern? Do we think the solution we should be training these things - 
which are meant to be better at producing code than others - to produce new 
code with this structure?

I'm sorry, using "I want a chatbot to be able to write better code" when the 
code pattern in question is not actually a good pattern is an unacceptable 
answer. If the tool cannot be trusted to produce code that is good or safe in 
particular areas, then the tool should not be used in them. Justifying a code 
change in these terms is absolutely unreasonable.

The only reasons that should be given for a code change like this should be 
related to actual implementation requirements. Not "I want the tool to generate 
differently problematic code that I believe is better".

That said, I have talked to @cor3ntin and he gave a much more reasonable 
explanation of why he was ok with this change.

I'm going to approve this PR, but I should not be needing to have someone other 
than a PR's author provide actual support for the change being made.

https://github.com/llvm/llvm-project/pull/238243
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to