sparse-llvm initialization of local vars

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

 



Hi,

I noticed that when local variables are initialized, only explicit
initialization instructions are output. But I think C requires that
the whole object be zeroed out as well.

Example code:

extern int printf(const char *s, ...);

struct foo {
long long int i,j;
};

static void dosomething(struct foo *foo)
{
printf("foo->i = %lld, foo->j = %lld\n", foo->i, foo->j);
}

int main(void)
{
struct foo foo = { 1, 2 };
struct foo bar = { 99 };
dosomething(&foo);
dosomething(&bar);
return 0;
}

In this example, sparse-llvm outputs garbage value for bar->j whereas
it should be 0.

To fix this, before any instructions for initialization is run,
sparse-llvm should zero out the whole object using LLVM intrinsic such
as memset. This is implemented in my repository.

Regards
Dibyendu
--
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