On Thu, 18 Aug 2011 12:28:01 +1000 Lex Trotman elextr@gmail.com wrote:
pmatch[2] = pmatch[3];
Well you obviously get away with it because it isn't really opaque (to the compiler), but it is still bad practice to assign such structures unless it is documented safe.
Instead of attempting to imagine how a swallow copy may go wrong, I decided to just assign the two members. libc _can't_ access them for it's own purposes, because it doesn't know the lifetime of pmatch.
Technically (gint)l == l is using implementation defined behavior, the standard says that the converting to a shorter signed type should give the same value if it fits, but if it doesn't fit, its implementation defined.
Yes, if 'l' becomes unsigned long, such a check will be unreliable...
then the comparison to G_MAXINT is a correct way of doing it.
...which always works, so let's play it safe again. Thanks.