I found a bug in pnm2ppa (allready reported upstream) that causes havoc with high optimization. A helper function of the command line parser forgets to allocate memory for a returned string, but instead uses the stack. This doesn't work with multiple options. My patch is for the gentoo-diff file, and patches pnm2ppa.c too
Created attachment 564 [details, diff] patch to pnm2ppa-1.0.91-r1-gentoo.diff
bit of a confusing patch you sent in the patch for the gentoo-diff in files doesn't change anything Anyway, thanks for the rest of the diff. I have committed it to portage.