Misc #21110
openShould Marshal.dump always use object links for repeated Float values?
Description
I've noticed (during the downstreaming ruby/spec in https://github.com/ruby/ruby/pull/12679) that a repeated Float value may be dumped "directly"/"immediately" without an object link on x86 architecture, and with a link in other cases. It seems it depends on whether Float is Flonum or not.
amd64:
i686:
Both dumps are loaded correctly, so it seems there is no any compatibility issue.
Should dumping be consistent and don't depend on architecture?
From https://github.com/ruby/ruby/pull/12679#discussion_r1937116017
Updated by Eregon (Benoit Daloze) over 1 year ago
IMO Marshal should not depend on obscure implementation details like Flonum, i.e. Float whether fitting in a Flonum or not should be dumped the same with Marshal.
What do others think?
Updated by Eregon (Benoit Daloze) over 1 year ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) over 1 year ago
Updated by Eregon (Benoit Daloze) over 1 year ago
Right, I think always adding a link makes sense.
Then the logic for flonum/not-flonum should be identical (as shown here).
Updated by herwin (Herwin W) over 1 year ago
nobu (Nobuyoshi Nakada) wrote in #note-3:
At least,
Floatshould be distinguished only by its value, not its object ID
Bigint has similar behaviour: