From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
Cc: | Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [RFC] Fix div/mul crash and more undefined behavior |
Date: | 2012-11-19 17:01:27 |
Message-ID: | 4671.1353344487@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Xi Wang <xi(dot)wang(at)gmail(dot)com> writes:
> The reality is that C compilers are not friendly to postcondition
> checking; they consider signed integer overflow as undefined behavior,
> so they do whatever they want to do. Even workaround options like
> -fwrapv are often broken, not to mention that they may not even have
> those options.
I think it's probably past time that we stopped guessing about this
sort of thing and added some regression test cases for it. I'm
planning to add cases like this:
-- check sane handling of INT_MIN overflow cases
SELECT (-2147483648)::int4 * (-1)::int4;
SELECT (-2147483648)::int4 / (-1)::int4;
SELECT (-2147483648)::int4 % (-1)::int4;
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Dimitri Fontaine | 2012-11-19 17:05:26 | Re: Dumping an Extension's Script |
Previous Message | Kevin Grittner | 2012-11-19 16:56:33 | Re: Materialized views WIP patch |