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

Re: [csmith-bugs] GCC Complaint: "init from incompatible pointer type"



Eric, is the Csmith code actually wrong or is it just giving an annoying warning? In general it's fine to add qualifiers, just not to delete them. For example Linux uses the idiom below which looks a lot like your example code but with one fewer levels of indirection. The important part is that when you make an atomic_t, it does not need to be volatile.

John


typedef struct {
    int counter;
} atomic_t;

#define atomic_read(v)      (*(volatile int *)&(v)->counter)
#define atomic_set(v,i)     (((v)->counter) = (i))




On 05/23/2013 08:36 AM, Eric Eide wrote:
Csmith (@ commit ac43da8, circa Mar 20 2013) sometimes generates code like
this:

	void foo()
	{
	    int *p = 0;
	    volatile int **q = &p;
	}

GCC 4.6.3 complains about this code, scolding:

	warning: initialization from incompatible pointer type [enabled by
	default]

I noticed this because my predicate script for C-Reduce looks for "incompatible
pointer type" warnings to weed out bad reduction steps.  When the original
program leads to such warnings, of course, my reductions cannot get off the
ground.

If you want a Csmith command line that leads to such generated code, please let
me know.

Eric.