Re: Optimisations and undefined behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/09/2015 02:56 PM, Richard Earnshaw wrote:
> On 09/11/15 14:29, Andrew Haley wrote:

>> Here it is again:
>>
>> int foo(int x) {
>> 	if (x > 1290) {
>> 		printf("X is wrong here %d, but we don't care\n", x);
>> 	}
>> 	return x*x*x;
>>
>> Here, the printf writes to a stream then the UB happens.  
> 
> Not if setvbuf has been used to make the stream unbuffered.

It hasn't.  And I know it hasn't because it's my example.

And besides, the UB might cause the computer to crash before the data
has been written to stdout by the kernel; the same reasoning applies.

Andrew.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux