nyoom,
@nyoom@akko.disqordia.space avatar

huh, TIL Julia pads structs to be multiples of 8 bytes to ensure memory alignment, cool

somehow I did not know that 🥴

Ukko,
@Ukko@akko.disqordia.space avatar

@nyoom this triggers the UB fear inside of me, this feels like it'd act differently on a big enhian system

nyoom,
@nyoom@akko.disqordia.space avatar

@Ukko yeah, I'm not quite sure why reinterpret isnt more clearly marked as unsafe the way most things that rely on memory layout in julia are. maybe because it can't cause memory corruption. I was just using reinterpret and sizeof to inspect the bit layout

(speaking of, that gives me an idea for a simple helper tool...)

Ukko,
@Ukko@akko.disqordia.space avatar

@nyoom what would happen if you try to reinterpret, eg, array of 3 int64s into an array ef structs each 2 int64s?

nyoom,
@nyoom@akko.disqordia.space avatar

@Ukko it throws an error

Ukko,
@Ukko@akko.disqordia.space avatar

@nyoom ok that's good i guess

nyoom,
@nyoom@akko.disqordia.space avatar

@Ukko I mean it has to really given that arrays are bounds-checked by default, so it needs to store the size of the resulting array somewhere

Ukko,
@Ukko@akko.disqordia.space avatar

@nyoom an alternative could've been padding everything with zeroes or dropping all the data not fitting in the struct

nyoom,
@nyoom@akko.disqordia.space avatar

@Ukko yeah, though that'd be confusing for multidimensional arrays ig

nyoom,
@nyoom@akko.disqordia.space avatar

@Ukko done, this should dump any isbits type into a hex code

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • Hentai
  • doujinshi
  • announcements
  • general
  • All magazines