Search code examples
c++bus-error

How to get a "bus error"?


I am trying very hard to get a bus error.

One way is misaligned access and I have tried the examples given here and here, but no error for me - the programs execute just fine.

Is there some situation which is sure to produce a bus error?


Solution

  • Bus errors can only be invoked on hardware platforms that:

    1. Require aligned access, and
    2. Don't compensate for an unaligned access by performing two aligned accesses and combining the results.

    You probably do not have access to such a system.