Skip to contentSkip to conversation

for (int i = expr; ....)

DISCUSSION Pierre Habouzit 2 participants 3 messages Feb 21, 2008 – Feb 23, 2008 Sparse checker

lore
Share & tools
lore
#0 lore raw

Sparse doesn't support the C99 construct for (int i = expr; ....) properly. for example, the following C code:

    #include <stdlib.h>

    int main(void)
    {
        for (int i = atoi("12"); i < 10; i++);
        return 0;
    }

make sparse spit:

    $ sparse -Wall test.c
    test.c:5:22: warning: call with no type!

In fact sparse doesn't support 'expr' to be a complex enough expression (expressions that can be folded work, but not any other afaict).

I assume something has to be done in parser.c, but I'm not really sure it's the sole place…

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org
#1 lore raw
Quoted 11 lines · Pierre Habouzit

Sparse doesn't support the C99 construct for (int i = expr; ....) properly.
for example, the following C code:

    #include <stdlib.h>

    int main(void)
    {
        for (int i = atoi("12"); i < 10; i++);
        return 0;
    }
Quoted 7 lines

make sparse spit:

    $ sparse -Wall test.c
    test.c:5:22: warning: call with no type!

In fact sparse doesn't support 'expr' to be a complex enough expression (expressions that can be folded work, but not any other afaict).

Nah, sparse supports expression in initializer all right. It just need to evaluate them to give it the correct ctype.

Please try the this one line patch I attached.

Chris

#2 lore raw
Quoted 18 lines · Chris Li
Quoted 16 lines · Pierre Habouzit

Sparse doesn't support the C99 construct for (int i = expr; ....) properly.
for example, the following C code:

    #include <stdlib.h>

    int main(void)
    {
        for (int i = atoi("12"); i < 10; i++);
        return 0;
    }

make sparse spit:

    $ sparse -Wall test.c
    test.c:5:22: warning: call with no type!
Quoted 7 lines
Quoted 2 lines

In fact sparse doesn't support 'expr' to be a complex enough expression (expressions that can be folded work, but not any other afaict).

Nah, sparse supports expression in initializer all right. It just need to evaluate them to give it the correct ctype.

Please try the this one line patch I attached.

Works for me, thanks.

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org