* declaration specifiers wooziness
@ 2007-06-27 10:33 Alexey Dobriyan
2007-06-27 15:01 ` Josh Triplett
0 siblings, 1 reply; 11+ messages in thread
From: Alexey Dobriyan @ 2007-06-27 10:33 UTC (permalink / raw)
To: linux-sparse; +Cc: adobriyan
sparse silently accepts some peculiar combinations of declaration
specifiers:
"typedef extern;" passes.
"void char a;" errors about void declaration, however,
"extern void char a;" passes. Hey, "extern void a;" passes!
"char short a;" passes too. Ditto for "char float a;" and
"char long a".
"typedef inline a;" passes.
Not sure how many different bugs there are here, though...
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 10:33 declaration specifiers wooziness Alexey Dobriyan
@ 2007-06-27 15:01 ` Josh Triplett
2007-06-27 15:16 ` Derek M Jones
0 siblings, 1 reply; 11+ messages in thread
From: Josh Triplett @ 2007-06-27 15:01 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: linux-sparse, adobriyan
On Wed, 2007-06-27 at 14:33 +0400, Alexey Dobriyan wrote:
> sparse silently accepts some peculiar combinations of declaration
> specifiers:
>
> "typedef extern;" passes.
>
> "void char a;" errors about void declaration, however,
> "extern void char a;" passes. Hey, "extern void a;" passes!
>
> "char short a;" passes too. Ditto for "char float a;" and
> "char long a".
>
> "typedef inline a;" passes.
>
> Not sure how many different bugs there are here, though...
Several more:
int;
void;
int *;
void *;
static;
extern;
volatile;
static foo;
extern foo;
volatile foo;
int volatile;
- Josh Triplett
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:01 ` Josh Triplett
@ 2007-06-27 15:16 ` Derek M Jones
2007-06-27 15:31 ` Alexey Dobriyan
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Derek M Jones @ 2007-06-27 15:16 UTC (permalink / raw)
To: Josh Triplett; +Cc: Alexey Dobriyan, linux-sparse, adobriyan
Alex, Josh,
> On Wed, 2007-06-27 at 14:33 +0400, Alexey Dobriyan wrote:
>> sparse silently accepts some peculiar combinations of declaration
>> specifiers:
These are all permitted by the syntax of C.
6.7 Declarations, the init-declarator-list is optional.
>> "typedef extern;" passes.
...
>> Not sure how many different bugs there are here, though...
Sparse might flag the usage as suspicious, but it is not a bug.
> Several more:
The syntax permits:
signed unsigned short long double int;
>
> int;
> void;
> int *;
> void *;
> static;
> extern;
> volatile;
> static foo;
> extern foo;
> volatile foo;
> int volatile;
>
> - Josh Triplett
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:derek@knosof.co.uk
Applications Standards Conformance Testing http://www.knosof.co.uk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:16 ` Derek M Jones
@ 2007-06-27 15:31 ` Alexey Dobriyan
2007-06-27 15:34 ` Derek M Jones
2007-06-27 15:39 ` Al Viro
2007-06-27 15:39 ` Josh Triplett
2 siblings, 1 reply; 11+ messages in thread
From: Alexey Dobriyan @ 2007-06-27 15:31 UTC (permalink / raw)
To: Derek M Jones; +Cc: Josh Triplett, linux-sparse, adobriyan
On Wed, Jun 27, 2007 at 04:16:29PM +0100, Derek M Jones wrote:
> The syntax permits:
>
> signed unsigned short long double int;
Please, read 6.7.2(2).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:31 ` Alexey Dobriyan
@ 2007-06-27 15:34 ` Derek M Jones
2007-06-27 15:44 ` Derek M Jones
0 siblings, 1 reply; 11+ messages in thread
From: Derek M Jones @ 2007-06-27 15:34 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Josh Triplett, linux-sparse, adobriyan
Alexey Dobriyan wrote:
> On Wed, Jun 27, 2007 at 04:16:29PM +0100, Derek M Jones wrote:
>> The syntax permits:
>>
>> signed unsigned short long double int;
>
> Please, read 6.7.2(2).
Semantic spoil sport.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:derek@knosof.co.uk
Applications Standards Conformance Testing http://www.knosof.co.uk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:16 ` Derek M Jones
2007-06-27 15:31 ` Alexey Dobriyan
@ 2007-06-27 15:39 ` Al Viro
2007-06-27 15:39 ` Josh Triplett
2 siblings, 0 replies; 11+ messages in thread
From: Al Viro @ 2007-06-27 15:39 UTC (permalink / raw)
To: Derek M Jones; +Cc: Josh Triplett, Alexey Dobriyan, linux-sparse, adobriyan
On Wed, Jun 27, 2007 at 04:16:29PM +0100, Derek M Jones wrote:
> These are all permitted by the syntax of C.
>
> 6.7 Declarations, the init-declarator-list is optional.
See 6.7[2]; the things like
int ;
violate the constraint.
> >>"typedef extern;" passes.
> ...
> >>Not sure how many different bugs there are here, though...
>
> Sparse might flag the usage as suspicious, but it is not a bug.
See 6.7.1[2]; no more than one storage class specifier in a declaration.
> >Several more:
>
> The syntax permits:
>
> signed unsigned short long double int;
See 6.7.2[2]; the set you've given is not in the list given there.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:16 ` Derek M Jones
2007-06-27 15:31 ` Alexey Dobriyan
2007-06-27 15:39 ` Al Viro
@ 2007-06-27 15:39 ` Josh Triplett
2007-06-27 15:41 ` Al Viro
2 siblings, 1 reply; 11+ messages in thread
From: Josh Triplett @ 2007-06-27 15:39 UTC (permalink / raw)
To: Derek M Jones; +Cc: Alexey Dobriyan, linux-sparse, adobriyan
On Wed, 2007-06-27 at 16:16 +0100, Derek M Jones wrote:
> Alex, Josh,
>
> > On Wed, 2007-06-27 at 14:33 +0400, Alexey Dobriyan wrote:
> >> sparse silently accepts some peculiar combinations of declaration
> >> specifiers:
>
> These are all permitted by the syntax of C.
>
> 6.7 Declarations, the init-declarator-list is optional.
Huh; interesting. That explains "int volatile;" as well; it doesn't
parse as an attempt to declare an integer named volatile, but as a
declaration with no variable.
> >> "typedef extern;" passes.
> ...
> >> Not sure how many different bugs there are here, though...
>
> Sparse might flag the usage as suspicious, but it is not a bug.
Probably not worth the trouble of flagging.
> > Several more:
>
> The syntax permits:
>
> signed unsigned short long double int;
I would hope it does not permit "double int".
Sparse will in fact spew errors about *that* syntax:
/dev/stdin:1:8: error: You cannot have both signed and unsigned modifiers.
/dev/stdin:1:17: error: You cannot have both signed and unsigned modifiers.
/dev/stdin:1:23: error: You cannot have both long and short modifiers.
/dev/stdin:1:23: error: You cannot have both signed and unsigned modifiers.
/dev/stdin:1:28: error: modifier [signed] [unsigned] is invalid in this context
/dev/stdin:1:28: error: You cannot have both signed and unsigned modifiers.
/dev/stdin:1:35: error: Trying to use reserved word 'int' as identifier
- Josh Triplett
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:39 ` Josh Triplett
@ 2007-06-27 15:41 ` Al Viro
0 siblings, 0 replies; 11+ messages in thread
From: Al Viro @ 2007-06-27 15:41 UTC (permalink / raw)
To: Josh Triplett; +Cc: Derek M Jones, Alexey Dobriyan, linux-sparse, adobriyan
On Wed, Jun 27, 2007 at 08:39:35AM -0700, Josh Triplett wrote:
> On Wed, 2007-06-27 at 16:16 +0100, Derek M Jones wrote:
> > Alex, Josh,
> >
> > > On Wed, 2007-06-27 at 14:33 +0400, Alexey Dobriyan wrote:
> > >> sparse silently accepts some peculiar combinations of declaration
> > >> specifiers:
> >
> > These are all permitted by the syntax of C.
> >
> > 6.7 Declarations, the init-declarator-list is optional.
>
> Huh; interesting. That explains "int volatile;" as well; it doesn't
> parse as an attempt to declare an integer named volatile, but as a
> declaration with no variable.
It is optional for structs, unions and enums.
> > >> "typedef extern;" passes.
> > ...
> > >> Not sure how many different bugs there are here, though...
> >
> > Sparse might flag the usage as suspicious, but it is not a bug.
>
> Probably not worth the trouble of flagging.
... only because any compiler is going to throw up on it anyway.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:34 ` Derek M Jones
@ 2007-06-27 15:44 ` Derek M Jones
2007-06-27 15:48 ` Josh Triplett
2007-06-27 16:00 ` Al Viro
0 siblings, 2 replies; 11+ messages in thread
From: Derek M Jones @ 2007-06-27 15:44 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Josh Triplett, linux-sparse, adobriyan
All,
>>> The syntax permits:
>>>
>>> signed unsigned short long double int;
>>
>> Please, read 6.7.2(2).
>
> Semantic spoil sport.
The point I did not mention before sending the email
was the extent to which Sparse needs to check constructs
that are constraint violations and thus assumed to be checked
by the compiler.
Ok, it is possible to get weird looking stuff through sparse
without complaint, but is it worth spending time flagging it?
Surely time should be concentrated on flagging suspicious constructs
that are valid C and not in correctly handling obscure corners
of the language.
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:derek@knosof.co.uk
Applications Standards Conformance Testing http://www.knosof.co.uk
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:44 ` Derek M Jones
@ 2007-06-27 15:48 ` Josh Triplett
2007-06-27 16:00 ` Al Viro
1 sibling, 0 replies; 11+ messages in thread
From: Josh Triplett @ 2007-06-27 15:48 UTC (permalink / raw)
To: Derek M Jones; +Cc: Alexey Dobriyan, linux-sparse, adobriyan
On Wed, 2007-06-27 at 16:44 +0100, Derek M Jones wrote:
> All,
>
> >>> The syntax permits:
> >>>
> >>> signed unsigned short long double int;
> >>
> >> Please, read 6.7.2(2).
> >
> > Semantic spoil sport.
>
> The point I did not mention before sending the email
> was the extent to which Sparse needs to check constructs
> that are constraint violations and thus assumed to be checked
> by the compiler.
>
> Ok, it is possible to get weird looking stuff through sparse
> without complaint, but is it worth spending time flagging it?
>
> Surely time should be concentrated on flagging suspicious constructs
> that are valid C and not in correctly handling obscure corners
> of the language.
Ideally, I would like Sparse to provide a self-contained set of
warnings, even those potentially redundant with a compiler. However, I
agree that in general Sparse should give priority to issues that a
compiler will not already flag.
- Josh Triplett
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: declaration specifiers wooziness
2007-06-27 15:44 ` Derek M Jones
2007-06-27 15:48 ` Josh Triplett
@ 2007-06-27 16:00 ` Al Viro
1 sibling, 0 replies; 11+ messages in thread
From: Al Viro @ 2007-06-27 16:00 UTC (permalink / raw)
To: Derek M Jones; +Cc: Alexey Dobriyan, Josh Triplett, linux-sparse, adobriyan
On Wed, Jun 27, 2007 at 04:44:17PM +0100, Derek M Jones wrote:
> The point I did not mention before sending the email
> was the extent to which Sparse needs to check constructs
> that are constraint violations and thus assumed to be checked
> by the compiler.
>
> Ok, it is possible to get weird looking stuff through sparse
> without complaint, but is it worth spending time flagging it?
Yes, if they turn into problems later on. One practical reason
is that we are short on MOD_... bits; carrying MOD_LONG et.al.
might be a bad idea - we might want to choose the right integer
type (as in, the right struct symbol out of small set) and be
done with those; conversions can be done that way just fine, we
don't need to look at MOD_LONG et.al. for those.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-06-27 16:00 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-27 10:33 declaration specifiers wooziness Alexey Dobriyan
2007-06-27 15:01 ` Josh Triplett
2007-06-27 15:16 ` Derek M Jones
2007-06-27 15:31 ` Alexey Dobriyan
2007-06-27 15:34 ` Derek M Jones
2007-06-27 15:44 ` Derek M Jones
2007-06-27 15:48 ` Josh Triplett
2007-06-27 16:00 ` Al Viro
2007-06-27 15:39 ` Al Viro
2007-06-27 15:39 ` Josh Triplett
2007-06-27 15:41 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).