Barry A. Warsaw writes:
Of course the first 'foo' and the second 'foo' need not have such a close lexical relationship. And can't interning (I think) be disabled? (Though I'm sure no one does this.) Also, isn't interning limited to just identifier-like strings:
Yes, but in practice, the strings that were used for exceptions were simple in this way. I don't know whether there's a #define that controls the use of interning; I can't imaging that anyone would want to use it.
So, yes the simple example I gave will work, but the more general concept, that string exceptions cannot guaranteed to be caught by value, still holds.
Agreed. But that's always been well-known, and probably even documented. ;-)