Re: C as intermediate language, signed integer overflow and -ftrapv

2014-08-09 Thread Thomas Mertes
On Jul 30, 2014, at 16:39 Geert Bosch wrote: > On Jul 23, 2014, at 10:56 AM, Thomas Mertes wrote: > > > One such feature is the detection of signed integer overflow. It is > > not hard, to detect signed integer overflow with a generated C > > program, but the performance is certainly not optimal

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-30 Thread Geert Bosch
On Jul 23, 2014, at 10:56 AM, Thomas Mertes wrote: > One such feature is the detection of signed integer overflow. It is > not hard, to detect signed integer overflow with a generated C > program, but the performance is certainly not optimal. Signed integer > overflow is undefined behavior in C

Re: Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-29 Thread Richard Biener
On Tue, Jul 29, 2014 at 1:17 PM, Thomas Mertes wrote: > On Mon, Jul 28, 2014 at 11:49 AM, Richard Biener > wrote: >> On Sun, Jul 27, 2014 at 9:13 AM, Thomas Mertes wrote: >> > On Fri, Jul 25, 2014 at 12:35, Richard Biener >> > wrote: >> >> On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes >>

Aw: Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-29 Thread Thomas Mertes
On Mon, Jul 28, 2014 at 11:49 AM, Richard Biener wrote: > On Sun, Jul 27, 2014 at 9:13 AM, Thomas Mertes wrote: > > On Fri, Jul 25, 2014 at 12:35, Richard Biener > > wrote: > >> On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes > >> wrote: > >> > On Thu, Jul 24 at 10:36 PM, Richard Biener >

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-28 Thread Richard Biener
On Sun, Jul 27, 2014 at 9:13 AM, Thomas Mertes wrote: > On Fri, Jul 25, 2014 at 12:35, Richard Biener > wrote: >> On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes wrote: >> > On Thu, Jul 24 at 10:36 PM, Richard Biener >> > wrote: >> >> Fact is that if somebody is interested in >> >> -ftrapv he

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-27 Thread Thomas Mertes
On Fri, Jul 25, 2014 at 12:35, Richard Biener wrote: > On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes wrote: > > On Thu, Jul 24 at 10:36 PM, Richard Biener > > wrote: > >> Fact is that if somebody is interested in > >> -ftrapv he/she is welcome to contribute patches. Especially testing > >>

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-25 Thread Joseph S. Myers
On Fri, 25 Jul 2014, Richard Biener wrote: > Note the slight complication with static initializers that _do_ have > to simplify to something (well, maybe not with -ftrapv ...). Joseph, > I can easily make fold fail if you don't explicitely use a constant > folding API (int_const_binop) and -ftrap

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-25 Thread Richard Biener
On Fri, Jul 25, 2014 at 12:41 PM, Richard Biener wrote: > On Fri, Jul 25, 2014 at 12:35 PM, Richard Biener > wrote: >> On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes wrote: >>> On Thu, Jul 24 at 10:36 PM, Richard Biener >>> wrote: Fact is that if somebody is interested in -ftrapv he

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-25 Thread Richard Biener
On Fri, Jul 25, 2014 at 12:35 PM, Richard Biener wrote: > On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes wrote: >> On Thu, Jul 24 at 10:36 PM, Richard Biener >> wrote: >>> Fact is that if somebody is interested in >>> -ftrapv he/she is welcome to contribute patches. Especially testing >>> cov

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-25 Thread Richard Biener
On Fri, Jul 25, 2014 at 10:43 AM, Thomas Mertes wrote: > On Thu, Jul 24 at 10:36 PM, Richard Biener wrote: >> Fact is that if somebody is interested in >> -ftrapv he/she is welcome to contribute patches. Especially testing >> coverage is poor. > > As I said I have test programs for integer overf

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-25 Thread Thomas Mertes
On Thu, Jul 24 at 10:36 PM, Richard Biener wrote: > Fact is that if somebody is interested in > -ftrapv he/she is welcome to contribute patches. Especially testing > coverage is poor. As I said I have test programs for integer overflow (not written in C). Now I have converted one test program to

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-24 Thread Marek Polacek
On Wed, Jul 23, 2014 at 04:56:06PM +0200, Thomas Mertes wrote: > A sanitizer such as ubsan is good as tool to find errors in C > programs. But I don't think that ubsan is well suited to do overflow > detection with maximum performance. Is just not the goal of this > tool. That's true. But if you

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-24 Thread Richard Biener
On Wed, Jul 23, 2014 at 9:56 PM, David Wohlferd wrote: > I believe that sometimes gcc is promoting the ints to long longs when doing > the overflow testing. If I try to overflow a long long, I get the trap as > expected. Yes, I think that's one issue - see https://gcc.gnu.org/bugzilla/show_bug.c

Re: C as intermediate language, signed integer overflow and -ftrapv

2014-07-23 Thread David Wohlferd
I believe that sometimes gcc is promoting the ints to long longs when doing the overflow testing. If I try to overflow a long long, I get the trap as expected. See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19020 dw On 7/23/2014 7:56 AM, Thomas Mertes wrote: C is popular as intermedi

C as intermediate language, signed integer overflow and -ftrapv

2014-07-23 Thread Thomas Mertes
C is popular as intermediate language. This means that some compilers generate C and use a C compiler as backend. Wikipedia lists several languages, which use C as intermediate language: Eiffel, Sather, Esterel, some dialects of Lisp (Lush, Gambit), Haskell (Glasgow Haskell Compiler), Squeak's Smal