I've managed to run into this as well. Here's a C++ version that runs
into the same problem when compiled with `g++ -fsanitize=address
-fsanitize=undefined`:

struct Hash {
    alignas(64) unsigned long acc[8]{0};
    unsigned int s1 {0};
};

struct B {
    unsigned int hash() const {
        return m_hash.s1;
    }
    
    Hash m_hash;
};

int main(int argc, char** argv) {
    B b1;
    static_assert(alignof(b1) == 64);

    // This will not cause a misaligned address error
    // return b1.m_hash.s1 > 0;

    // This will cause the error
    return b1.hash() > 0;
}

I can also confirm that the UBSAN error indeed goes away when
ASAN_OPTIONS=detect_stack_use_after_return=false is used and that this
problem does not occur on either Fedora 39 (GCC 13.3.1) or Fedora 40
(GCC 14.2.1).

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2023424

Title:
  GCC 13 on Lunar exhibits AddressSanitizer/UndefinedBehaviorSanitizer
  bug that doesn't manifest elsewhere

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-13/+bug/2023424/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to