1. You have a specifically "undefined behavior" -- meaning that you are relying upon a side effect that is not guaranteed. This is permitted to work differently (or not at all, or randomly) on different compilers. See http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 for more.
2. If your predicate returns properly, you should only see the output for one item. This is an error with the way LLVC is compiling your program. Are you using any unusual compiler directives?
Also, you are doing something screwy with the end argument. (Don't do that.) Your function should look something like this:
1 2 3 4 5 6
template <typename T, typename P>
bool test(T begin, T end, P p) {
for(; (begin != end) && p(*begin, *begin); )
/* no body */ ;
return (begin == end);
}