The problem comes from the construction of Stream operations, which happens at the point a tagged type is frozen. Streams need to see the full view of types, so that for example the Read attribute for an array can be expanded into a loop over the Read attribute for the component type. Now if during that expansion we have a private type we may need to retrieve the full view of the type to find its structure. And the corresponding tree must be compiled in the context of the package that defines the type, which might not be the current package. The problem arises when both array and component types are private, then the described mechanism is invoked twice. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Compile_Stream_Body_In_Scope): Do not install package if array type and element type come from the same package, and the original array type is private.