Hi Mikael, Am 08.12.21 um 10:32 schrieb Mikael Morin: > On 07/12/2021 21:46, Harald Anlauf wrote: >> Hi Mikael, >> >> Am 07.12.21 um 21:17 schrieb Mikael Morin: >>> The existing code looks dubious to me (or at least difficult to >>> understand), and your patch doesn’t make that any better. >>> I would rather try to remove the whole block, and fix the fallout on >>> move_alloc by adding calls to gfc_check_vardef_context in >>> gfc_check_move_alloc. >>> Can you try that instead? >> >> I hadn't thought that far but will think about a possibly better >> solution. >> > Hello, > > I thought about it some more over night, and it is probably a poor > suggestion to restrict the check to move_alloc only.  The existing code > was added for move_alloc, but it has a broader scope.  Still, > gfc_check_vardef_context has the correct checks and is the one to be used. I have played a little, and it took some time to understand the fallout. Your suggestion to rely on gfc_check_vardef_context actually helped to uncover another bug: a bad check for CLASS pointer. See attached for an updated patch and the extended testcase. Regtested again. OK now? Thanks, Harald