January 16, 2013
mist:

> Yes and this is the very difference between compiler and static analysis tool, in my opinion. Compiler should never ever reject valid use cases, it does not matter how small chance of meeting those is.

In most cases debugging is an inherently statistical thing because large programs always contain many bugs. In programming life you can't work with absolutes, you should look at the probabilities too.


> Also I am not Walter and second question has probably been targeted wrong :)

Walter time is probably better spent elsewhere. If you have understood well what Walter meant, you should be able to write that a counterexample in that enhancement request.

Bye,
bearophile
January 16, 2013
On 2013-01-16 12:17, mist wrote:

> Yes and this is the very difference between compiler and static analysis
> tool, in my opinion. Compiler should never ever reject valid use cases,
> it does not matter how small chance of meeting those is.

Clang contains a ton of warnings for code that could contain common errors. I mean, there's nothing wrong in having unreferenced variables but there are still compilers that warn about this.

Also not that Clang has a static analyzer, in addition to the warnings and errors in the compiler.

-- 
/Jacob Carlborg
January 16, 2013
> 	class B {
> 		protected int a=123;
> 	}
>
> 	class A : B {
> 		int f(int b) {
> 			//int a;	// <--- I forgot to write this line
> 			...
> 			a = b + 1;	// <---  Oops!
> 			...
> 			return a;
> 		}
> 	}

That's why I don't understand, why D allows to refer to member variables and functions without "this". I always use "this" and don't have any problems.
January 16, 2013
On Wednesday, 16 January 2013 at 11:50:18 UTC, bearophile wrote:
> mist:
>
>> Yes and this is the very difference between compiler and static analysis tool, in my opinion. Compiler should never ever reject valid use cases, it does not matter how small chance of meeting those is.
>
> In most cases debugging is an inherently statistical thing because large programs always contain many bugs. In programming life you can't work with absolutes, you should look at the probabilities too.

Yes, I fully agree with you. That is way having a solid static analysis tool is must for low-level language. But compiler has different job and I like it UNIX-way.

>> Also I am not Walter and second question has probably been targeted wrong :)
>
> Walter time is probably better spent elsewhere. If you have understood well what Walter meant, you should be able to write that a counterexample in that enhancement request.

No idea how well I have understood, but I'll scratch a code example, no problem.

January 16, 2013
On Wednesday, 16 January 2013 at 12:05:49 UTC, Jacob Carlborg wrote:
> On 2013-01-16 12:17, mist wrote:
>
>> Yes and this is the very difference between compiler and static analysis
>> tool, in my opinion. Compiler should never ever reject valid use cases,
>> it does not matter how small chance of meeting those is.
>
> Clang contains a ton of warnings for code that could contain common errors. I mean, there's nothing wrong in having unreferenced variables but there are still compilers that warn about this.
>
> Also not that Clang has a static analyzer, in addition to the warnings and errors in the compiler.

Well, that is probably the only thing I hate in Clang :) Also, I can't imagine a single valid use case for unreferenced variables in C/C++, so it is a bit different.
January 16, 2013
On Wednesday, January 16, 2013 13:53:04 mist wrote:
> Well, that is probably the only thing I hate in Clang :) Also, I can't imagine a single valid use case for unreferenced variables in C/C++, so it is a bit different.

RAII.

- Jonathan M Davis
January 16, 2013
On Wednesday, 16 January 2013 at 15:49:14 UTC, Jonathan M Davis wrote:
> On Wednesday, January 16, 2013 13:53:04 mist wrote:
>> Well, that is probably the only thing I hate in Clang :) Also, I
>> can't imagine a single valid use case for unreferenced variables
>> in C/C++, so it is a bit different.
>
> RAII.
>
> - Jonathan M Davis

Have just checked it - clang does not treat variable as unused if it does have use-defined destructor. Which makes sense from my understanding of word "unused".
January 16, 2013
On Wednesday, 16 January 2013 at 12:53:05 UTC, mist wrote:
> On Wednesday, 16 January 2013 at 12:05:49 UTC, Jacob Carlborg wrote:
>> Clang contains a ton of warnings for code that could contain common errors. […]
>
> Well, that is probably the only thing I hate in Clang :)

Actually, I found GCC to be much noisier in this (-Wall -Wextra) case; the Clang warnings are mostly of pretty good quality.


> Also, I can't imagine a single valid use case for unreferenced variables in C/C++, so it is a bit different.

Variables only used as parameters to assert(), in release builds. This is somewhat annoying, as there isn't already an #if-block you could move them into, as for other similar cases involving conditional compilation.

David
January 16, 2013
On Wednesday, 16 January 2013 at 16:58:13 UTC, David Nadlinger wrote:
> On Wednesday, 16 January 2013 at 12:53:05 UTC, mist wrote:
>> On Wednesday, 16 January 2013 at 12:05:49 UTC, Jacob Carlborg wrote:
>>> Clang contains a ton of warnings for code that could contain common errors. […]
>>
>> Well, that is probably the only thing I hate in Clang :)
>
> Actually, I found GCC to be much noisier in this (-Wall -Wextra) case; the Clang warnings are mostly of pretty good quality.
>
>
>> Also, I can't imagine a single valid use case for unreferenced variables in C/C++, so it is a bit different.
>
> Variables only used as parameters to assert(), in release builds. This is somewhat annoying, as there isn't already an #if-block you could move them into, as for other similar cases involving conditional compilation.
>
> David

Ah, good catch, glad I have not yet met such a case, I'd probably have raged a lot :) Well, both Clang and GCC are not perfect here. I have seen several times when -Werror policy got canceled because no acceptable workaround was thought of in time. And my development experience is rather small.
January 20, 2013
On Thursday, 10 January 2013 at 03:42:54 UTC, deadalnix wrote:
>
> So authority argument worth more than actual data. That is noted.

You may argue that it's authority, but unless you love petty arguments, you can't argue that it's not a very well known and very widespread usage practice. No need to collect stats to know that.