Re: more "unreplaced symbol" warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 1, 2011 at 12:41 AM, Christopher Li <sparse@xxxxxxxxxxx> wrote:
> #define __u16 unsigned short
> int foo(__u16 n);
> static inline __u16 f(__u16 val)
> {
>        return val;
> }
>
> static inline unsigned int bar(__u16 n)
> {
>       switch (n) {
>       case (1 ? 1 : f(1)):
>               return 4;
>       }
> }
>
> int foo(__u16 n)
> {
>        bar(n);
>        bar(n);
>        return 0;
> }

I just submit a fix for this bug. It took me a few days staring at the
inlining code to figure out what is going on. I am glad this is bug is
resolved now.

The example above is actually the minimal setup to trigger this
bug. The root cause is in one of the member during copying case statement
did not replace to the new statement. e.g. when inlining f(), it actually
change the original copy of function definition in bar().

The warning is triggered during the second time bar() get inlined.

The fix is just one line. Finding it is the hard part.

Chris

@@ -381,6 +381,7 @@ static struct statement *copy_one_statement(struct
statement *stmt)
        case STMT_CASE: {
                stmt = dup_statement(stmt);
                stmt->case_label = copy_symbol(stmt->pos, stmt->case_label);
+               stmt->case_label->stmt = stmt;
                stmt->case_expression = copy_expression(stmt->case_expression);
                stmt->case_to = copy_expression(stmt->case_to);
                stmt->case_statement = copy_one_statement(stmt->case_statement);
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux