Hello, here come several patches to fix the infamous PR 45586. The main issue is the middle-end expecting variant types to share the fields, thus one field cannot be restrict qualified in one type, and not restrict qualified in one of its variants. The fix, as per Richi's suggestion, makes the types not be variants of each other, but this raises type compatibility problems, as fold_convert triggers an assertion if the types are not variants of the same base type. The fix for that (suggested by Richi again) wraps the expression in a VIEW_CONVERT_EXPR. The above is not enough to make LTO happy. There are problems with structure constructors, where we use the restricted type, but the variable to assign to is a target, thus has a non-restrict type. The fix for that propagates the information that we don't want restrict qualification from gfc_trans_assignment down to gfc_conv_structure. The same applies to array constructors. The patch is split as follows: [1/5]: Add the VIEW_CONVERT_EXPR wrapping. [2/5]: Make target vs. non-target variant types distinct. [3/5]: Use the target information to assign from structure constructors. [4/5]: Use the target information to assign from array constructors. [5/5]: Use the target information to assign a scalar structure to an array. More details in the follow-up mails. Regression tested on amd64-linux. OK for trunk? Mikael