Re: [PATCH] Fix UB in diagnostic.c

2014-08-17 Thread Dodji Seketeli
Marek Polacek a écrit: > On Wed, Aug 13, 2014 at 09:03:37PM +0200, Manuel López-Ibáñez wrote: >> I don't think this is the right fix. The problem is that we are trying >> to print the caret in a column that is larger than the line_width. We >> do this because the file given by the line directive

Re: [PATCH] Fix UB in diagnostic.c

2014-08-14 Thread Marek Polacek
On Wed, Aug 13, 2014 at 09:03:37PM +0200, Manuel López-Ibáñez wrote: > I don't think this is the right fix. The problem is that we are trying > to print the caret in a column that is larger than the line_width. We > do this because the file given by the line directive has nothing to do > with the a

Re: [PATCH] Fix UB in diagnostic.c

2014-08-13 Thread Manuel López-Ibáñez
> This should fix an undefined behavior in diagnostics.c. > Under certain circumstances, max_width is (INT_MAX - 1), > and right_margin is -4 -> the subtraction overflows. > Changing the types to unsigned would involve changing > much more code than just one cast. > > BTW, the diagnostics we output

[PATCH] Fix UB in diagnostic.c

2014-08-13 Thread Marek Polacek
This should fix an undefined behavior in diagnostics.c. Under certain circumstances, max_width is (INT_MAX - 1), and right_margin is -4 -> the subtraction overflows. Changing the types to unsigned would involve changing much more code than just one cast. BTW, the diagnostics we output for the test