Veteran Member
|
Hi there..
I am experimenting with some template stuff in Xcode.. I have a strange problem... When I step through them using Debug everything is fine.. The IO log window outputs what I expect, and the trace of the code is faultless.. Variables and pointers all behave impeccably.. However, when I run it 'for real' in Xcode I get exceptions... Anyone know of any quirks with templates and Xcode? It's pretty basic stuff. Nothing fancy. I have tried all the dumb stuff.. Cleaning, reloading everything etc. etc. 'Remember, measure life by the moments that take your breath away, not by how many breaths you take' Extreme Sports Cafe | ESC's blog | scratt's blog | @thescratt |
quote |
Veteran Member
Join Date: May 2004
|
Er, do you mean project templates, or C++ templates?
|
quote |
Veteran Member
|
Quote:
Actually I solved it about 10 minutes ago.. I was talking about C++ templates. It was very wierd.. One of those 1 in a million bugs.. A pointer in a routine about half a page up was overwriting the end of some string space and randomly affecting the code, causing crashes... But it only manifested itself after I had included a whole load of templates for repetative search functions.. I must be using so many levels of indirection that the compiler didn't pick up the fact that I was writing wildy outside the boundaries of my data... Strange... But that'll teach me to try and be clever... 'Remember, measure life by the moments that take your breath away, not by how many breaths you take' Extreme Sports Cafe | ESC's blog | scratt's blog | @thescratt |
|
quote |
Veteran Member
Join Date: May 2004
|
The compiler won't.
C++ doesn't have any concept of writing past the end of an array, you're welcome to do it. Heck, it doesn't have the concept of writing before the beginning of the array either. Had a boss do the following once as a down and dirty 'struct' for a three dimensional array: const int LEN = X * Y * Z; int a[LEN + 3]; a = a +3; a[0]...a[LEN] acted as expected. a[-3]...a[-1] were storage for the lengths of the each axis. So you always had the proper sizes being carried around with it. In theory. Personally, I thought he was bonkers, but it worked pretty well... until the day a student misread the documentation... oy. The point is, you can have an array that's N long, and access [N*10] if you want, or [-N]. C/C++ won't care, and won't stop you. Glad you got it figured out. |
quote |
Posting Rules | Navigation |
|
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Why does software crash, freeze and hang? | dahacouk | General Discussion | 32 | 2005-11-15 14:48 |