2 ms·
I get that assert() is a macro, but how does that affect the scope of char *p that it "works" in one case and segfaults (as I'd expect) in the other?
by bch 15y ago
I get that assert() is a macro, but how does that affect the scope of char *p that it "works" in one case and segfaults (as I'd expect) in the other?
- bch 15y agoOK -- I wasn't looking at this clearly. In case there are others like me: * the scope of *p is only global. My comment re: scope is just Wrong. * there is never a call to someinitialization() *execpt* via the assert. If no assert() is called, the Bad Value prevails; if the assert() is called, it resets *p. I feel a bit foolish, but found it easy to misread this at first glance. If anybody else didn't get it initially, hopefully this helps :P I thought there was deeper magic, but it's really just programming flow, and knowing good practices re: assert() (or anything that has side effects).