Problem while executing a custom testcase inside testsuite

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem while executing a custom testcase inside testsuite

Akshat Garg
Hello all,

I have been trying to run a test which assigns a value from non-atomic to
an atomic pointer type. The code is as follows:

/* File: xyz.c  */
/* { dg-do compile } */
/* { dg-options "-std=c11 -pedantic-errors" } */

#include <stdatomic.h>

typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern void exit (int);
extern void *malloc (size_t);


struct rcutest
{
  int a;
  int b;
  int c;
};

_Atomic struct rcutest *gp;

#define rcu_assign_pointer(p,v) \
  atomic_store_explicit(&(p), (v), memory_order_release);

#define rcu_dereference(p) \
  atomic_load_explicit(&(p), memory_order_consume);

void thread0 ()
{
  struct rcutest *p;
  p = (struct rcutest *)malloc (sizeof (*p));
  if (p)
    abort();
  p->a = 42;
  if (p->a == 43)
    abort();
  rcu_assign_pointer (gp,p);
}

The test is inside the gcc.dg directory of the testsuite.
The command used to run the specific test: make -k check-c
RUNTESTFLAG="dg.exp=xyz.c"

I believe I should be getting a warning like:
warning: initialization from incompatible pointer type
[-Wincompatible-pointer-types]
but in the gcc.log file, I found this:
error: initialization of '_Atomic struct rcutest *' from incompatible
pointer type 'struct rcutest *' [-Wincompatible-pointer-types]

Can anyone please explain to me why this is considered as an error, not a
warning?

Thanks,
Akshat
Reply | Threaded
Open this post in threaded view
|

Re: Problem while executing a custom testcase inside testsuite

Andreas Schwab-2
On Jun 22 2019, Akshat Garg <[hidden email]> wrote:

> I believe I should be getting a warning like:
> warning: initialization from incompatible pointer type
> [-Wincompatible-pointer-types]
> but in the gcc.log file, I found this:
> error: initialization of '_Atomic struct rcutest *' from incompatible
> pointer type 'struct rcutest *' [-Wincompatible-pointer-types]
>
> Can anyone please explain to me why this is considered as an error, not a
> warning?

Because it's a pedwarn, and you are passing -pedantic-errors.

Andreas.

--
Andreas Schwab, [hidden email]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: Problem while executing a custom testcase inside testsuite

Akshat Garg
On Sat, Jun 22, 2019 at 1:10 PM Andreas Schwab <[hidden email]>
wrote:

> On Jun 22 2019, Akshat Garg <[hidden email]> wrote:
>
> > I believe I should be getting a warning like:
> > warning: initialization from incompatible pointer type
> > [-Wincompatible-pointer-types]
> > but in the gcc.log file, I found this:
> > error: initialization of '_Atomic struct rcutest *' from incompatible
> > pointer type 'struct rcutest *' [-Wincompatible-pointer-types]
> >
> > Can anyone please explain to me why this is considered as an error, not a
> > warning?
>
> Because it's a pedwarn, and you are passing -pedantic-errors.
>
So, can you tell me what should I pass for pedwarn. I tried with
-pedwarn-errors, but it didn't work.

>
> Andreas.
>
> --
> Andreas Schwab, [hidden email]
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem while executing a custom testcase inside testsuite

Jonathan Wakely-4
On Sat, 22 Jun 2019 at 12:25, Akshat Garg <[hidden email]> wrote:

>
> On Sat, Jun 22, 2019 at 1:10 PM Andreas Schwab <[hidden email]>
> wrote:
>
> > On Jun 22 2019, Akshat Garg <[hidden email]> wrote:
> >
> > > I believe I should be getting a warning like:
> > > warning: initialization from incompatible pointer type
> > > [-Wincompatible-pointer-types]
> > > but in the gcc.log file, I found this:
> > > error: initialization of '_Atomic struct rcutest *' from incompatible
> > > pointer type 'struct rcutest *' [-Wincompatible-pointer-types]
> > >
> > > Can anyone please explain to me why this is considered as an error, not a
> > > warning?
> >
> > Because it's a pedwarn, and you are passing -pedantic-errors.
> >
> So, can you tell me what should I pass for pedwarn. I tried with
> -pedwarn-errors, but it didn't work.

-pedantic of course. Try looking in the GCC manual, instead of just
guessing at option names.
Reply | Threaded
Open this post in threaded view
|

Re: Problem while executing a custom testcase inside testsuite

Akshat Garg
On Sun, Jun 23, 2019 at 3:27 AM Jonathan Wakely <[hidden email]>
wrote:

> On Sat, 22 Jun 2019 at 12:25, Akshat Garg <[hidden email]> wrote:
> >
> > On Sat, Jun 22, 2019 at 1:10 PM Andreas Schwab <[hidden email]>
> > wrote:
> >
> > > On Jun 22 2019, Akshat Garg <[hidden email]> wrote:
> > >
> > > > I believe I should be getting a warning like:
> > > > warning: initialization from incompatible pointer type
> > > > [-Wincompatible-pointer-types]
> > > > but in the gcc.log file, I found this:
> > > > error: initialization of '_Atomic struct rcutest *' from incompatible
> > > > pointer type 'struct rcutest *' [-Wincompatible-pointer-types]
> > > >
> > > > Can anyone please explain to me why this is considered as an error,
> not a
> > > > warning?
> > >
> > > Because it's a pedwarn, and you are passing -pedantic-errors.
> > >
> > So, can you tell me what should I pass for pedwarn. I tried with
> > -pedwarn-errors, but it didn't work.
>
> -pedantic of course. Try looking in the GCC manual, instead of just
> guessing at option names.
>
I found it earlier but forget to reply. Thanks anyway for your time.