Created attachment 23474 [details] Testcase
I fail to see what the missed optimization is, can you try to explain?
A null pointer check (... && ! &p->i) is not eliminated, notwithstanding the fact that the pointer has been dereferenced. If it is not null, bar is not called; otherwise, there is an undefined behavior, and bar is not called. Or is it too an unimportant problem? (It's interesting, after changing S_ptr p to struct S *p, the non-LTO build also fails with "undefined reference to `bar'".)
Hm, ok. It's surely worth investigating.
I can't reproduce it with GCC 4.6.4, 4.7.3, 4.8.0.