On Thu, Aug 28, 2014 at 11:20 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Pavan Deolasee <pavan.deolasee@gmail.com> writes: > Can some kind of compiler optimisation reorder things such that the "else > if" expression is evaluated using the old, uninitialised value of optval?
Any such behavior is patently illegal per the C standard.
Thanks a lot for explaining that.
Not that that's always stopped compiler writers; but I think you might be looking at a compiler bug.
I'd requested the reporter to try moving the getsockopt() call outside "if" expression. That hasn't helped. So I think its a case of getsockopt() neither returning an error nor setting optval to any sane value. Will try to get more details about the platform etc.