• Aux@feddit.uk
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 天前

        Internally it will still read a whole word. Because the CPU cannot read less than a word. And if you read the ARM article you linked, it literally says so.

        Thus any compiler worth their salt will align all byte variables to words for faster memory access. Unless you specifically disable such behaviour. So yeah, RTFM :)

        • timhh@programming.dev
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          1 天前

          Wrong again. It depends on the CPU. They can absolutely read a single byte and they will do if you’re reading from non-idempotent memory.

          If you’re reading from idempotent memory they won’t read a byte or a word. They’ll likely read a whole cache line (usually 64 bytes).

          And if you read the ARM article you linked, it literally says so.

          Where?

          Thus any compiler worth their salt will align all byte variables to words for faster memory access.

          No they won’t because it isn’t faster. The CPU will read the whole cache line that contains the byte.

          RTFM

          Well, I would but no manual says that because it’s wrong!

          • Aux@feddit.uk
            link
            fedilink
            English
            arrow-up
            1
            arrow-down
            1
            ·
            1 天前

            The fuck are you talking about, kiddo? Read the fucking docs!

            • timhh@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 天前

              What docs? A bool is one byte. Get over it. Find me one normal compiler/architecture in C, C++, Go, Rust, Zig, etc. where it is not. Go on.