* Undetected error cases
@ 2008-06-01 18:42 Vegard Nossum
2008-06-01 18:55 ` Vegard Nossum
2008-06-01 18:58 ` Pavel Roskin
0 siblings, 2 replies; 5+ messages in thread
From: Vegard Nossum @ 2008-06-01 18:42 UTC (permalink / raw)
To: linux-sparse
Hi,
I was playing with sparse to see what it would accept, and I was
actually surprised at how many "obviously wrong" constructs it
accepted. Because sparse is supposed to warn about this, isn't it? Or
is there a policy not to warn about things that gcc already rejects?
If that were the case, I believe it would reduce the overall
usefulness of sparse.
(I say "obviously wrong" because I don't see how they can be valid,
but I might of course be mistaken :-))
Anyway, here are my test cases:
==> const-void.c <==
/* "const void" has no meaning. */
const void f(void);
==> extern-parameter.c <==
/* "extern" in parameter declaration has no meaning. */
void f(extern int x);
==> inline-parameter.c <==
/* "inline" in parameter declaration has no meaning. */
void f(inline int x);
==> inline-typedef.c <==
/* "inline" is in front of "typedef". Is this equivalent to
* "typedef inline int t"? Even so, it doesn't make sense to make variables
* inline. */
inline typedef t;
==> inline-variable.c <==
/* "inline" for variables has no meaning. */
static inline int x = 0;
==> typedef-collision.c <==
/* Two types with the same name. The second one is used, but should it
* be allowed? */
typedef char t;
typedef int t;
static t my_t = 0;
==> typedef-parameter.c <==
/* "typedef" in parameter declaration has no meaning. */
void f(typedef x);
None of these produce errors or even warnings when they are run
through sparse. I probably won't get around to fixing these myself
since I'm not that familiar with sparse internals. This is just a
heads up :-)
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Undetected error cases
2008-06-01 18:42 Undetected error cases Vegard Nossum
@ 2008-06-01 18:55 ` Vegard Nossum
2008-06-01 18:58 ` Pavel Roskin
1 sibling, 0 replies; 5+ messages in thread
From: Vegard Nossum @ 2008-06-01 18:55 UTC (permalink / raw)
To: linux-sparse
On Sun, Jun 1, 2008 at 8:42 PM, Vegard Nossum <vegard.nossum@gmail.com> wrote:
> I was playing with sparse to see what it would accept, and I was
> actually surprised at how many "obviously wrong" constructs it
> accepted. Because sparse is supposed to warn about this, isn't it? Or
> is there a policy not to warn about things that gcc already rejects?
> If that were the case, I believe it would reduce the overall
> usefulness of sparse.
>
> (I say "obviously wrong" because I don't see how they can be valid,
> but I might of course be mistaken :-))
>
> Anyway, here are my test cases:
>
Here are some more that all produce errors or at least warnings with
gcc but pass silently with sparse:
==> extern-struct.c <==
/* Empty declaration */
extern struct t {
};
==> inline-struct.c <==
/* "inline" has no meaning here. */
inline struct t {
};
==> struct-struct.c <==
/* What does this mean? */
struct struct {
};
==> struct-typedef.c <==
/* Anonymous typedef or struct named "typedef"? */
struct typedef {
};
==> typedef-cast.c <==
/* Cast to typedef doesn't make sense. */
static int x = (typedef int) 0;
==> typedef-struct.c <==
/* Anonymous typedef? */
typedef struct {
};
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Undetected error cases
2008-06-01 18:42 Undetected error cases Vegard Nossum
2008-06-01 18:55 ` Vegard Nossum
@ 2008-06-01 18:58 ` Pavel Roskin
2008-06-01 19:46 ` Vegard Nossum
1 sibling, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2008-06-01 18:58 UTC (permalink / raw)
To: Vegard Nossum; +Cc: linux-sparse
On Sun, 2008-06-01 at 20:42 +0200, Vegard Nossum wrote:
> None of these produce errors or even warnings when they are run
> through sparse. I probably won't get around to fixing these myself
> since I'm not that familiar with sparse internals. This is just a
> heads up :-)
Still, you may be able to create test cases for the testsuite.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Undetected error cases
2008-06-01 18:58 ` Pavel Roskin
@ 2008-06-01 19:46 ` Vegard Nossum
2008-06-01 20:10 ` Pavel Roskin
0 siblings, 1 reply; 5+ messages in thread
From: Vegard Nossum @ 2008-06-01 19:46 UTC (permalink / raw)
To: Pavel Roskin; +Cc: linux-sparse
On Sun, Jun 1, 2008 at 8:58 PM, Pavel Roskin <proski@gnu.org> wrote:
> On Sun, 2008-06-01 at 20:42 +0200, Vegard Nossum wrote:
>
>> None of these produce errors or even warnings when they are run
>> through sparse. I probably won't get around to fixing these myself
>> since I'm not that familiar with sparse internals. This is just a
>> heads up :-)
>
> Still, you may be able to create test cases for the testsuite.
Ah, that's be true. I have now submitted the .c files that should
produce the errors/warnings, but I can't seem to find an actual
testsuite in which to hook them. The existing test-* files seem to
test the API, not the files to be parsed.
Vegard
--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Undetected error cases
2008-06-01 19:46 ` Vegard Nossum
@ 2008-06-01 20:10 ` Pavel Roskin
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Roskin @ 2008-06-01 20:10 UTC (permalink / raw)
To: Vegard Nossum; +Cc: linux-sparse
On Sun, 2008-06-01 at 21:46 +0200, Vegard Nossum wrote:
> Ah, that's be true. I have now submitted the .c files that should
> produce the errors/warnings, but I can't seem to find an actual
> testsuite in which to hook them. The existing test-* files seem to
> test the API, not the files to be parsed.
It's under "validation".
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-01 20:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-01 18:42 Undetected error cases Vegard Nossum
2008-06-01 18:55 ` Vegard Nossum
2008-06-01 18:58 ` Pavel Roskin
2008-06-01 19:46 ` Vegard Nossum
2008-06-01 20:10 ` Pavel Roskin
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).