Hey,
i have a reg_word, which I'd like to bitmask.
e.g.
However, I get a segmentation fault. Anybody have an idea where that could come from?Code:void bitmask(reg_word a) { reg_word b = 0xf0; reg_word c = (a & b); }
Hey,
i have a reg_word, which I'd like to bitmask.
e.g.
However, I get a segmentation fault. Anybody have an idea where that could come from?Code:void bitmask(reg_word a) { reg_word b = 0xf0; reg_word c = (a & b); }
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
A segfault without a pointer in sight - now that's something new.
Do you have a gdb backtrace to show us?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
the method is called by 3rd party code and I do not really more about it. a is supposedly 32 bit wide and I don't see a pointer, but maybe in the 3rd party code?
I'm not really an experienced C coder, I don't know how I could do a gdb backtrace.
Run the code in the debugger.
gdb ./myprog
Then type 'run' at the prompt.
When it crashes, type 'bt' and post what it prints.
> I'm not really an experienced C coder
Is there anyone near to you that is?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I did it differently now: Shift first, and then bitmask. Now it does work for some reason.
Thanks for your help