Re: Optimisations and undefined behaviour

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

 



On 11/09/2015 04:00 PM, Andrew Haley wrote:
> 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.

If the printf has no effect, you can obviously leave it out.

I think the goal here was to convince me that even if the printf has a
visible effect (in the sense that I could read its output), it is still
conforming to remove it.  This is the part I have problems with.

Florian



[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