https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62117
yuta tomino <demoonlit at panathenaia dot halfmoon.jp> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |---
--- Comment #2 from yuta tomino <demoonlit at panathenaia dot halfmoon.jp> ---
Thank you for looking, Eric.
Surely, as you say, memcmp is unsuitable for presenting an example.
It's my mistake. But I had not found other case at the time.
I found another case since then. Pure is not a trigger in this case.
Please look this, too.
In the new case, it uses Float'Valid attribute calling
System.Fat_Flt.Unaligned_Valid implicitly.
Unaligned_Valid takes an Address argument. But it's not marked as pure.
And, it's a detail of compiler implementation. I think this behavior should not
affect application code.
It needs the type U for calling Unaligned_Valid.
If this type is removed (and some other method like Unchecked_Conversion is
used), System.Fat_Flt.Valid may be called instead of Unaligned_Valid.
System.Fat_Flt.Valid works correctly.
I apologize for taking your time.
-- case2.ads
package case2 is
-- not pure package
function Packed_Unaligned_Valid (Item : Long_Long_Integer) return Boolean;
-- not pure function
end case2;
-- case2.adb
with system.storage_elements;
package body case2 is
use type System.Storage_Elements.Storage_Offset;
-- A Float value is packed into the argument Item, at unaligned position.
type U is record
C : Character;
F : Float;
end record;
pragma Pack (U);
function Packed_Unaligned_Valid (Item : Long_Long_Integer) return Boolean is
X : U;
for X'Address use Item'Address;
begin
return X.F'Valid; -- implicit calling System.Fat_Flt.Unaligned_Valid
end Packed_Unaligned_Valid;
end case2;
==== gcc-4.9 ====
_case2__packed_unaligned_valid:
LFB3:
subq $24, %rsp
LCFI0:
leaq 9(%rsp), %rdi
call _system__fat_flt__attr_float__unaligned_valid
addq $24, %rsp
LCFI1:
ret
=== gcc-4.8 ====
_case2__packed_unaligned_valid:
LFB3:
subq $24, %rsp
LCFI0:
movq %rdi, 8(%rsp) # this operation is missing in gcc-4.9
leaq 9(%rsp), %rdi
call _system__fat_flt__attr_float__unaligned_valid
addq $24, %rsp
LCFI1:
ret