Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Thu, 15 Feb 2007, Sergei Organov wrote: >> >> I agree that if the warning has no true positives, it sucks. The problem >> is that somehow I doubt it has none. And the reasons for the doubt are: > > Why do you harp on "no true positives"? Because if

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Bodo Eggert <[EMAIL PROTECTED]> writes: > On Fri, 16 Feb 2007, Sergei Organov wrote: [...] > I'll say it again: Either the code using unspecified chars is correct, or > it isn't. If it's correct, neither using with signed nor with unsigned > chars is a bug and you should not warn at all, and

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Rene Herman <[EMAIL PROTECTED]> writes: [...] > Given char's special nature, shouldn't the conclusion of this thread > have long been simply that gcc needs -Wno-char-pointer-sign? (with > whatever default, as far as I'm concerned). I entirely agree that all the char business in C is messy enough

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Bodo Eggert <[EMAIL PROTECTED]> writes: > On Fri, 16 Feb 2007, Sergei Organov wrote: >> Bodo Eggert <[EMAIL PROTECTED]> writes: >> > Sergei Organov <[EMAIL PROTECTED]> wrote: >> >> Linus Torvalds <[EMAIL PROTECTED]> writes: > [...] >> If we start talking about the C language, my opinion is that

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Bodo Eggert [EMAIL PROTECTED] writes: On Fri, 16 Feb 2007, Sergei Organov wrote: Bodo Eggert [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: [...] If we start talking about the C language, my opinion is that it's C problem that it

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Rene Herman [EMAIL PROTECTED] writes: [...] Given char's special nature, shouldn't the conclusion of this thread have long been simply that gcc needs -Wno-char-pointer-sign? (with whatever default, as far as I'm concerned). I entirely agree that all the char business in C is messy enough to

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Bodo Eggert [EMAIL PROTECTED] writes: On Fri, 16 Feb 2007, Sergei Organov wrote: [...] I'll say it again: Either the code using unspecified chars is correct, or it isn't. If it's correct, neither using with signed nor with unsigned chars is a bug and you should not warn at all, and if it's

Re: somebody dropped a (warning) bomb

2007-02-19 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Thu, 15 Feb 2007, Sergei Organov wrote: I agree that if the warning has no true positives, it sucks. The problem is that somehow I doubt it has none. And the reasons for the doubt are: Why do you harp on no true positives? Because if somebody is

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Bodo Eggert
On Fri, 16 Feb 2007, Sergei Organov wrote: > Bodo Eggert <[EMAIL PROTECTED]> writes: > > Sergei Organov <[EMAIL PROTECTED]> wrote: > >> Linus Torvalds <[EMAIL PROTECTED]> writes: > > If you don't code for a specific compiler with specific settings, there is > > no implementation defining the

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Bodo Eggert
On Fri, 16 Feb 2007, Sergei Organov wrote: > Bodo Eggert <[EMAIL PROTECTED]> writes: > > Sergei Organov <[EMAIL PROTECTED]> wrote: > >> Linus Torvalds <[EMAIL PROTECTED]> writes: > [...] > > Using signed chars for strings is wrong in most countries on earth. It was > > wrong when the first IBM PC

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Sergei Organov
Bodo Eggert <[EMAIL PROTECTED]> writes: > Sergei Organov <[EMAIL PROTECTED]> wrote: >> Linus Torvalds <[EMAIL PROTECTED]> writes: > >>> Exactly because "char" *by*definition* is "indeterminate sign" as far as >>> something like "strlen()" is concerned. >> >> Thanks, I now understand that you

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Sergei Organov
Bodo Eggert <[EMAIL PROTECTED]> writes: > Sergei Organov <[EMAIL PROTECTED]> wrote: >> Linus Torvalds <[EMAIL PROTECTED]> writes: [...] > Using signed chars for strings is wrong in most countries on earth. It was > wrong when the first IBM PC came out in 1981, and creating a compiler in > 1987

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Sergei Organov
Bodo Eggert [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: [...] Using signed chars for strings is wrong in most countries on earth. It was wrong when the first IBM PC came out in 1981, and creating a compiler in 1987 defaulting to

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Sergei Organov
Bodo Eggert [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: Exactly because char *by*definition* is indeterminate sign as far as something like strlen() is concerned. Thanks, I now understand that you either don't see the

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Bodo Eggert
On Fri, 16 Feb 2007, Sergei Organov wrote: Bodo Eggert [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: [...] Using signed chars for strings is wrong in most countries on earth. It was wrong when the first IBM PC came out in

Re: somebody dropped a (warning) bomb

2007-02-16 Thread Bodo Eggert
On Fri, 16 Feb 2007, Sergei Organov wrote: Bodo Eggert [EMAIL PROTECTED] writes: Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: If you don't code for a specific compiler with specific settings, there is no implementation defining the signedness of char,

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Rene Herman
On 02/15/2007 08:02 PM, Linus Torvalds wrote: Think of it this way: in science, a theory is proven to be bad by a single undeniable fact just showing that it's wrong. The same is largely true of a warning. If the warning sometimes happens for code that is perfectly fine, the warning is bad.

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Lennart Sorensen
On Thu, Feb 15, 2007 at 07:57:05AM -0800, Linus Torvalds wrote: > I agree that it's "unnecessary code", and in many ways exactly the same > thing. I just happen to believe that casts tend to be a lot more dangerous > than extraneous initializations. Casts have this nasty tendency of hiding >

me, not somebody dropped a (warning) bomb

2007-02-15 Thread Oleg Verych
> From: Linus Torvalds > Newsgroups: gmane.linux.kernel > Subject: Re: somebody dropped a (warning) bomb > Date: Thu, 15 Feb 2007 11:02:32 -0800 (PST) [] > Think of it this way: in science, a theory is proven to be bad by a single > undeniable fact just showing that it's

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Bodo Eggert
Sergei Organov <[EMAIL PROTECTED]> wrote: > Linus Torvalds <[EMAIL PROTECTED]> writes: >> Exactly because "char" *by*definition* is "indeterminate sign" as far as >> something like "strlen()" is concerned. > > Thanks, I now understand that you either don't see the difference > between

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Olivier Galibert <[EMAIL PROTECTED]> writes: > On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: >> I agree that making strxxx() family special is not a good idea. So what >> do we do for a random foo(char*) called with an 'unsigned char*' >> argument? Silence? Hmmm... It's not

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Linus Torvalds
On Thu, 15 Feb 2007, Sergei Organov wrote: > > I agree that if the warning has no true positives, it sucks. The problem > is that somehow I doubt it has none. And the reasons for the doubt are: Why do you harp on "no true positives"? That's a pointless thing. You can make *any* warning have

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Thu, 15 Feb 2007, Sergei Organov wrote: [...Skip things I agree with...] >> > But if you have >> > >> >unsigned char *mystring; >> > >> >len = strlen(mystring); >> > >> > then please tell me how to fix that warning without making the code

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Linus Torvalds
On Thu, 15 Feb 2007, Sergei Organov wrote: > > Yes, there is. There are at least 2 drawbacks. Minor one is > initialization eating cycles. Major one is that if later I change the > code and there will appear a pass that by mistake uses those fake value, > I won't get the warning anymore. The

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Tue, 13 Feb 2007, Sergei Organov wrote: [...] > BUT (and this is a big but) within the discussion of "strlen()", that is > no longer true. "strlen()" exists _outside_ of a single particular > implementation. As such, "implementation-defined" is no

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Tue, 13 Feb 2007, Sergei Organov wrote: >> >> Sorry, what do you do with "variable 'xxx' might be used uninitialized" >> warning when it's false? Turn it off? Annotate the source? Assign fake >> initialization value? Change the compiler so that it

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Tue, 13 Feb 2007, Sergei Organov wrote: Sorry, what do you do with variable 'xxx' might be used uninitialized warning when it's false? Turn it off? Annotate the source? Assign fake initialization value? Change the compiler so that it does the

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Tue, 13 Feb 2007, Sergei Organov wrote: [...] BUT (and this is a big but) within the discussion of strlen(), that is no longer true. strlen() exists _outside_ of a single particular implementation. As such, implementation-defined is no longer

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Linus Torvalds
On Thu, 15 Feb 2007, Sergei Organov wrote: Yes, there is. There are at least 2 drawbacks. Minor one is initialization eating cycles. Major one is that if later I change the code and there will appear a pass that by mistake uses those fake value, I won't get the warning anymore. The latter

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Thu, 15 Feb 2007, Sergei Organov wrote: [...Skip things I agree with...] But if you have unsigned char *mystring; len = strlen(mystring); then please tell me how to fix that warning without making the code *worse* from a

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Linus Torvalds
On Thu, 15 Feb 2007, Sergei Organov wrote: I agree that if the warning has no true positives, it sucks. The problem is that somehow I doubt it has none. And the reasons for the doubt are: Why do you harp on no true positives? That's a pointless thing. You can make *any* warning have true

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Sergei Organov
Olivier Galibert [EMAIL PROTECTED] writes: On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: I agree that making strxxx() family special is not a good idea. So what do we do for a random foo(char*) called with an 'unsigned char*' argument? Silence? Hmmm... It's not immediately

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Bodo Eggert
Sergei Organov [EMAIL PROTECTED] wrote: Linus Torvalds [EMAIL PROTECTED] writes: Exactly because char *by*definition* is indeterminate sign as far as something like strlen() is concerned. Thanks, I now understand that you either don't see the difference between indeterminate and

me, not somebody dropped a (warning) bomb

2007-02-15 Thread Oleg Verych
From: Linus Torvalds Newsgroups: gmane.linux.kernel Subject: Re: somebody dropped a (warning) bomb Date: Thu, 15 Feb 2007 11:02:32 -0800 (PST) [] Think of it this way: in science, a theory is proven to be bad by a single undeniable fact just showing that it's wrong. If theory is very

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Lennart Sorensen
On Thu, Feb 15, 2007 at 07:57:05AM -0800, Linus Torvalds wrote: I agree that it's unnecessary code, and in many ways exactly the same thing. I just happen to believe that casts tend to be a lot more dangerous than extraneous initializations. Casts have this nasty tendency of hiding *other*

Re: somebody dropped a (warning) bomb

2007-02-15 Thread Rene Herman
On 02/15/2007 08:02 PM, Linus Torvalds wrote: Think of it this way: in science, a theory is proven to be bad by a single undeniable fact just showing that it's wrong. The same is largely true of a warning. If the warning sometimes happens for code that is perfectly fine, the warning is bad.

Re: somebody dropped a (warning) bomb

2007-02-14 Thread Sergei Organov
Olivier Galibert <[EMAIL PROTECTED]> writes: > On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: [...] >> May I suggest another definition for a warning being entirely sucks? >> "The warning is entirely sucks if and only if it never has true >> positives." In all other cases it's

Re: somebody dropped a (warning) bomb

2007-02-14 Thread Sergei Organov
Olivier Galibert [EMAIL PROTECTED] writes: On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: [...] May I suggest another definition for a warning being entirely sucks? The warning is entirely sucks if and only if it never has true positives. In all other cases it's only more or

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: > > Sorry, what do you do with "variable 'xxx' might be used uninitialized" > warning when it's false? Turn it off? Annotate the source? Assign fake > initialization value? Change the compiler so that it does "the effort" > for you? Never encountered

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Olivier Galibert
On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: > I agree that making strxxx() family special is not a good idea. So what > do we do for a random foo(char*) called with an 'unsigned char*' > argument? Silence? Hmmm... It's not immediately obvious that it's indeed > harmless. Yet

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Jeff Garzik
On Tue, Feb 13, 2007 at 11:29:44PM +0300, Sergei Organov wrote: > Sorry, what do you do with "variable 'xxx' might be used uninitialized" > warning when it's false? Turn it off? Annotate the source? Assign fake > initialization value? Change the compiler so that it does "the effort" > for you?

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Rob Landley
On Tuesday 13 February 2007 2:25 pm, Linus Torvalds wrote: > THE FACT IS, THAT "strlen()" IS DEFINED UNIVERSALLY AS TAKING "char *". > > That BY DEFINITION means that "strlen()" cannot care about the sign, > because the sign IS NOT DEFINED UNIVERSALLY! > > And if you cannot accept that fact,

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
"Pekka Enberg" <[EMAIL PROTECTED]> writes: > On 2/13/07, Sergei Organov <[EMAIL PROTECTED]> wrote: >> With almost any warning out there one makes more or less efforts to >> suppress the warning where it gives false positives, isn't it? > > Yes, as long it's the _compiler_ that's doing the effort.

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: > > Exactly because "char" *by*definition* is "indeterminate sign" as far as > > something like "strlen()" is concerned. > > Thanks, I now understand that you either don't see the difference > between "indeterminate" and "implementation-defined" in

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Tue, 13 Feb 2007, Sergei Organov wrote: >> > >> >"I want a char of indeterminate sign"! >> >> I'm afraid I don't follow. Do we have a way to say "I want an int of >> indeterminate sign" in C? The same way there doesn't seem to be a way >> to say

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Pekka Enberg
On 2/13/07, Sergei Organov <[EMAIL PROTECTED]> wrote: With almost any warning out there one makes more or less efforts to suppress the warning where it gives false positives, isn't it? Yes, as long it's the _compiler_ that's doing the effort. You shouldn't need to annotate the source just to

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: > > > > "I want a char of indeterminate sign"! > > I'm afraid I don't follow. Do we have a way to say "I want an int of > indeterminate sign" in C? The same way there doesn't seem to be a way > to say "I want a char of indeterminate sign". You're

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
"Pekka Enberg" <[EMAIL PROTECTED]> writes: > On 2/13/07, Sergei Organov <[EMAIL PROTECTED]> wrote: >> May I suggest another definition for a warning being entirely sucks? >> "The warning is entirely sucks if and only if it never has true >> positives." In all other cases it's only more or less

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Pekka Enberg
On 2/13/07, Sergei Organov <[EMAIL PROTECTED]> wrote: May I suggest another definition for a warning being entirely sucks? "The warning is entirely sucks if and only if it never has true positives." In all other cases it's only more or less sucks, IMHO. You're totally missing the point. False

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Mon, 12 Feb 2007, Sergei Organov wrote: >> >> Why strlen() should be allowed to be called with an incompatible pointer >> type? My point is that gcc should issue *different warning*, -- the same >> warning it issues here: > > I agree that "strlen()"

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Dick Streefland
Jan Engelhardt <[EMAIL PROTECTED]> wrote: | Further, giving again answer to the question whether they generate signed or | unsigned comparisons: Have you ever seen a computer which addresses memory with | negative numbers? Since the answer is most likely no, signed comparisons would | not make

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Dick Streefland
Jan Engelhardt [EMAIL PROTECTED] wrote: | Further, giving again answer to the question whether they generate signed or | unsigned comparisons: Have you ever seen a computer which addresses memory with | negative numbers? Since the answer is most likely no, signed comparisons would | not make

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Mon, 12 Feb 2007, Sergei Organov wrote: Why strlen() should be allowed to be called with an incompatible pointer type? My point is that gcc should issue *different warning*, -- the same warning it issues here: I agree that strlen() per se isn't

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Pekka Enberg
On 2/13/07, Sergei Organov [EMAIL PROTECTED] wrote: May I suggest another definition for a warning being entirely sucks? The warning is entirely sucks if and only if it never has true positives. In all other cases it's only more or less sucks, IMHO. You're totally missing the point. False

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Pekka Enberg [EMAIL PROTECTED] writes: On 2/13/07, Sergei Organov [EMAIL PROTECTED] wrote: May I suggest another definition for a warning being entirely sucks? The warning is entirely sucks if and only if it never has true positives. In all other cases it's only more or less sucks, IMHO.

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: I want a char of indeterminate sign! I'm afraid I don't follow. Do we have a way to say I want an int of indeterminate sign in C? The same way there doesn't seem to be a way to say I want a char of indeterminate sign. You're wrong.

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Pekka Enberg
On 2/13/07, Sergei Organov [EMAIL PROTECTED] wrote: With almost any warning out there one makes more or less efforts to suppress the warning where it gives false positives, isn't it? Yes, as long it's the _compiler_ that's doing the effort. You shouldn't need to annotate the source just to

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Tue, 13 Feb 2007, Sergei Organov wrote: I want a char of indeterminate sign! I'm afraid I don't follow. Do we have a way to say I want an int of indeterminate sign in C? The same way there doesn't seem to be a way to say I want a char of

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: Exactly because char *by*definition* is indeterminate sign as far as something like strlen() is concerned. Thanks, I now understand that you either don't see the difference between indeterminate and implementation-defined in this context or

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Sergei Organov
Pekka Enberg [EMAIL PROTECTED] writes: On 2/13/07, Sergei Organov [EMAIL PROTECTED] wrote: With almost any warning out there one makes more or less efforts to suppress the warning where it gives false positives, isn't it? Yes, as long it's the _compiler_ that's doing the effort. You

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Rob Landley
On Tuesday 13 February 2007 2:25 pm, Linus Torvalds wrote: THE FACT IS, THAT strlen() IS DEFINED UNIVERSALLY AS TAKING char *. That BY DEFINITION means that strlen() cannot care about the sign, because the sign IS NOT DEFINED UNIVERSALLY! And if you cannot accept that fact, it's your

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Jeff Garzik
On Tue, Feb 13, 2007 at 11:29:44PM +0300, Sergei Organov wrote: Sorry, what do you do with variable 'xxx' might be used uninitialized warning when it's false? Turn it off? Annotate the source? Assign fake initialization value? Change the compiler so that it does the effort for you? Never

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Olivier Galibert
On Tue, Feb 13, 2007 at 09:06:24PM +0300, Sergei Organov wrote: I agree that making strxxx() family special is not a good idea. So what do we do for a random foo(char*) called with an 'unsigned char*' argument? Silence? Hmmm... It's not immediately obvious that it's indeed harmless. Yet

Re: somebody dropped a (warning) bomb

2007-02-13 Thread Linus Torvalds
On Tue, 13 Feb 2007, Sergei Organov wrote: Sorry, what do you do with variable 'xxx' might be used uninitialized warning when it's false? Turn it off? Annotate the source? Assign fake initialization value? Change the compiler so that it does the effort for you? Never encountered false

Re: somebody dropped a (warning) bomb

2007-02-12 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: > > On Feb 9 2007 15:29, linux-os (Dick Johnson) wrote: >>> >>> I was referring to "absolute memory", not the offset magic that assembler >>> allows. After all, (reg+relativeOffset) will yield an absolute address. >>> What I was out at: for machines that

Re: somebody dropped a (warning) bomb

2007-02-12 Thread Linus Torvalds
On Mon, 12 Feb 2007, Sergei Organov wrote: > > Why strlen() should be allowed to be called with an incompatible pointer > type? My point is that gcc should issue *different warning*, -- the same > warning it issues here: I agree that "strlen()" per se isn't different. The issue is not that

Re: somebody dropped a (warning) bomb

2007-02-12 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Fri, 9 Feb 2007, Sergei Organov wrote: >> >> As far as I can read the C99 standard, the "char", "signed char", and >> "unsigned char", are all different types: > > Indeed. Search for "pseudo-unsigned", and you'll see more. There are > actually

Re: somebody dropped a (warning) bomb

2007-02-12 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Fri, 9 Feb 2007, Sergei Organov wrote: As far as I can read the C99 standard, the char, signed char, and unsigned char, are all different types: Indeed. Search for pseudo-unsigned, and you'll see more. There are actually cases where char can act

Re: somebody dropped a (warning) bomb

2007-02-12 Thread Linus Torvalds
On Mon, 12 Feb 2007, Sergei Organov wrote: Why strlen() should be allowed to be called with an incompatible pointer type? My point is that gcc should issue *different warning*, -- the same warning it issues here: I agree that strlen() per se isn't different. The issue is not that the

Re: somebody dropped a (warning) bomb

2007-02-12 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: On Feb 9 2007 15:29, linux-os (Dick Johnson) wrote: I was referring to absolute memory, not the offset magic that assembler allows. After all, (reg+relativeOffset) will yield an absolute address. What I was out at: for machines that have more than

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Martin Mares
Hello! > void* comparisons are unsigned. Period. As far as the C standard is concerned, there is no relationship between comparison on pointers and comparison of their values casted to uintptr_t. The address space needn't be linear and on some machines it isn't. So speaking about signedness of

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 9 2007 15:29, linux-os (Dick Johnson) wrote: >> >> I was referring to "absolute memory", not the offset magic that assembler >> allows. After all, (reg+relativeOffset) will yield an absolute address. >> What I was out at: for machines that have more than 2 GB of memory, you >> don't call

Re: somebody dropped a (warning) bomb

2007-02-09 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: > > On Feb 9 2007 08:16, linux-os (Dick Johnson) wrote: >> On Fri, 9 Feb 2007, Jan Engelhardt wrote: >>> On Feb 8 2007 16:42, Linus Torvalds wrote: >>> Further, giving again answer to the question whether they generate >>> signed or unsigned

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Pete Zaitcev
On Thu, 8 Feb 2007 22:27:43 -0500, "D. Hazelton" <[EMAIL PROTECTED]> wrote: > So almost all the rules around the signs of types are because of a single, > historical machine. Hence the rules about "char" being unsigned by default > and "int" being signed by default are because of the nature of

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 9 2007 08:16, linux-os (Dick Johnson) wrote: >On Fri, 9 Feb 2007, Jan Engelhardt wrote: >> On Feb 8 2007 16:42, Linus Torvalds wrote: >>> >> Further, giving again answer to the question whether they generate >> signed or unsigned comparisons: Have you ever seen a computer which >>

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Linus Torvalds
On Fri, 9 Feb 2007, Sergei Organov wrote: > > As far as I can read the C99 standard, the "char", "signed char", and > "unsigned char", are all different types: Indeed. Search for "pseudo-unsigned", and you'll see more. There are actually cases where "char" can act differently from _both_

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Linus Torvalds
On Thu, 8 Feb 2007, David Rientjes wrote: > > Yes, I read the 4.1.1 docs: > > By default, such a bit-field is signed, because this is > consistent: the basic integer types such as int are signed > types. Ok, so the gcc people have added some language. So what? The fact is,

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Sergei Organov
Jan Engelhardt <[EMAIL PROTECTED]> writes: > On Feb 8 2007 08:33, Linus Torvalds wrote: >> [...] > What C needs is a distinction between char and int8_t, rendering "char" > an unsigned at all times basically and making "unsigned char" and > "signed char" illegal types in turn. AFAIK, C already

Re: somebody dropped a (warning) bomb

2007-02-09 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: > > On Feb 8 2007 16:42, Linus Torvalds wrote: >> >> Most C types don't, and some you can't even tell (do pointers generate >> "signed" or "unsigned" comparisons? > > I'd say "neither", because both > >signed void *ptr; and >unsigned void *xyz; >

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Sergei Organov
Linus Torvalds <[EMAIL PROTECTED]> writes: > On Thu, 8 Feb 2007, Linus Torvalds wrote: >> >> But THE CALLER CANNOT AND MUST NOT CARE! Because the sign of "char" is >> implementation-defined, so if you call "strcmp()", you are already >> basically saying: I don't care (and I _cannot_ care) what

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 8 2007 16:42, Linus Torvalds wrote: > >Most C types don't, and some you can't even tell (do pointers generate >"signed" or "unsigned" comparisons? I'd say "neither", because both signed void *ptr; and unsigned void *xyz; are impossible (and dull at that). That's why you

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 8 2007 16:42, Linus Torvalds wrote: Most C types don't, and some you can't even tell (do pointers generate signed or unsigned comparisons? I'd say neither, because both signed void *ptr; and unsigned void *xyz; are impossible (and dull at that). That's why you explicitly will

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Sergei Organov
Linus Torvalds [EMAIL PROTECTED] writes: On Thu, 8 Feb 2007, Linus Torvalds wrote: But THE CALLER CANNOT AND MUST NOT CARE! Because the sign of char is implementation-defined, so if you call strcmp(), you are already basically saying: I don't care (and I _cannot_ care) what sign you are

Re: somebody dropped a (warning) bomb

2007-02-09 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: On Feb 8 2007 16:42, Linus Torvalds wrote: Most C types don't, and some you can't even tell (do pointers generate signed or unsigned comparisons? I'd say neither, because both signed void *ptr; and unsigned void *xyz; are impossible

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Sergei Organov
Jan Engelhardt [EMAIL PROTECTED] writes: On Feb 8 2007 08:33, Linus Torvalds wrote: [...] What C needs is a distinction between char and int8_t, rendering char an unsigned at all times basically and making unsigned char and signed char illegal types in turn. AFAIK, C already has 3

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Linus Torvalds
On Thu, 8 Feb 2007, David Rientjes wrote: Yes, I read the 4.1.1 docs: By default, such a bit-field is signed, because this is consistent: the basic integer types such as int are signed types. Ok, so the gcc people have added some language. So what? The fact is, that

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Linus Torvalds
On Fri, 9 Feb 2007, Sergei Organov wrote: As far as I can read the C99 standard, the char, signed char, and unsigned char, are all different types: Indeed. Search for pseudo-unsigned, and you'll see more. There are actually cases where char can act differently from _both_ unsigned char

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 9 2007 08:16, linux-os (Dick Johnson) wrote: On Fri, 9 Feb 2007, Jan Engelhardt wrote: On Feb 8 2007 16:42, Linus Torvalds wrote: Further, giving again answer to the question whether they generate signed or unsigned comparisons: Have you ever seen a computer which addresses memory

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Pete Zaitcev
On Thu, 8 Feb 2007 22:27:43 -0500, D. Hazelton [EMAIL PROTECTED] wrote: So almost all the rules around the signs of types are because of a single, historical machine. Hence the rules about char being unsigned by default and int being signed by default are because of the nature of the PDP-11.

Re: somebody dropped a (warning) bomb

2007-02-09 Thread linux-os \(Dick Johnson\)
On Fri, 9 Feb 2007, Jan Engelhardt wrote: On Feb 9 2007 08:16, linux-os (Dick Johnson) wrote: On Fri, 9 Feb 2007, Jan Engelhardt wrote: On Feb 8 2007 16:42, Linus Torvalds wrote: Further, giving again answer to the question whether they generate signed or unsigned comparisons: Have you

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Jan Engelhardt
On Feb 9 2007 15:29, linux-os (Dick Johnson) wrote: I was referring to absolute memory, not the offset magic that assembler allows. After all, (reg+relativeOffset) will yield an absolute address. What I was out at: for machines that have more than 2 GB of memory, you don't call the address

Re: somebody dropped a (warning) bomb

2007-02-09 Thread Martin Mares
Hello! void* comparisons are unsigned. Period. As far as the C standard is concerned, there is no relationship between comparison on pointers and comparison of their values casted to uintptr_t. The address space needn't be linear and on some machines it isn't. So speaking about signedness of

Re: somebody dropped a (warning) bomb

2007-02-08 Thread D. Hazelton
On Thursday 08 February 2007 19:42, Linus Torvalds wrote: > Most C types don't, and some you can't even tell (do pointers generate > "signed" or "unsigned" comparisons? I'll argue that a compiler that > generates signed comparisons for them is broken, but it tends to be > something you can only

Re: somebody dropped a (warning) bomb

2007-02-08 Thread David Rientjes
On Thu, 8 Feb 2007, Linus Torvalds wrote: > Even gcc DOES DIFFERENT THINGS! Have you even read the docs? > > By default it is treated as signed int but this may be changed by > the -funsigned-bitfields option. > Yes, I read the 4.1.1 docs: By default, such a bit-field is

Re: somebody dropped a (warning) bomb

2007-02-08 Thread Linus Torvalds
On Thu, 8 Feb 2007, David Rientjes wrote: > > Maybe you should read my first post, we're talking about gcc's behavior > here, not the C standard. Give it up, David. Even gcc DOES DIFFERENT THINGS! Have you even read the docs? By default it is treated as signed int but this may be

Re: somebody dropped a (warning) bomb

2007-02-08 Thread David Rientjes
On Thu, 8 Feb 2007, Linus Torvalds wrote: > No it's not. > > You just don't understand the C language. > > And if you don't understand the C language, you can't say "that's what the > int says". It says no such thing. > > The C language clearly says that bitfields have implementation-defined

Re: somebody dropped a (warning) bomb

2007-02-08 Thread Linus Torvalds
On Thu, 8 Feb 2007, Linus Torvalds wrote: > > The C language clearly says that bitfields have implementation-defined > types. Btw, this isn't even some "theoretical discussion". LOTS of compilers do unsigned bitfields. It may even be the majority. There may (or may not) be some correlation

Re: somebody dropped a (warning) bomb

2007-02-08 Thread Linus Torvalds
On Thu, 8 Feb 2007, David Rientjes wrote: > > Your struct: > > struct dummy { > int flag:1; > } a_variable; > > should expect a_varible.flag to be signed, that's what the int says. No it's not. You just don't understand the C language. And if you don't

Re: somebody dropped a (warning) bomb

2007-02-08 Thread David Rientjes
On Thu, 8 Feb 2007, Linus Torvalds wrote: > No, making bitfields unsigned is actually usually a good idea. It allows > you to often generate better code, and it actually tends to be what > programmers _expect_. A lot of people seem to be surprised to hear that a > one-bit bitfield actually

Re: somebody dropped a (warning) bomb

2007-02-08 Thread Linus Torvalds
On Fri, 9 Feb 2007, J.A. Magallón wrote: > > Thats the point. Mmmm, I think I see it the other way around. I defined > a variable as 'signed' or 'unsigned', because the sign info matters for me. > And gcc warns about using a function on it that will _ignore_ or even > misinterpret that info.

  1   2   >