• Fonzie!@ttrpg.network
        link
        fedilink
        arrow-up
        1
        ·
        3 days ago

        And sensible compile times.

        I’m trying to write a game in Bevy but my laptop’s Intel 7400 taking almost a minute to compile even small changes is really killing me.
        I’ve looked up rustc compile times on different CPUs and am seriously considering getting a new laptop with a Snapdragon X Elite or something in that vein for this.

      • Lucy :3@feddit.org
        link
        fedilink
        arrow-up
        9
        arrow-down
        8
        ·
        9 days ago

        Should ≠ Needs to

        You can do it, and it will work, but it’s unclean and not best-practice. I wouldn’t be surprised if it’s undefined behaviour.

        • xmunk@sh.itjust.works
          link
          fedilink
          arrow-up
          22
          ·
          9 days ago

          Just to clarify. It is defined behavior - there’s plenty of undefined behavior in C but that ain’t one of them.

          • FuckBigTech347@lemmygrad.ml
            link
            fedilink
            arrow-up
            2
            ·
            9 days ago

            Interesting feature, I had no idea. I just verified this with gcc and indeed the return register is always set to 0 before returning unless otherwise specified.

            spoiler
            int main(void)
            {
                int foo = 10;
            }
            

            produces:

            push   %rbp
            mov    %rsp,%rbp
            movl   $0xa,-0x4(%rbp) # Move 10 to stack variable
            mov    $0x0,%eax       # Return 0
            pop    %rbp
            ret
            
            int main(void)
            {
                int foo = 10;
                return foo;
            }
            

            produces:

            push   %rbp
            mov    %rsp,%rbp
            movl   $0xa,-0x4(%rbp) # Move 10 to stack variable
            mov    -0x4(%rbp),%eax # Return foo
            pop    %rbp
            ret