clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

Warning on shared pointer assignment that discards qualifiers #24

Closed nenadv closed 10 years ago

nenadv commented 10 years ago

The following code produces warnings:

shared int *s;
int
main ()
{
  strict shared int *p = upc_alloc (5);
  strict shared int *a = s;
}
$ ../../bld/bin/clangupc -c t.upc
t.upc:9:22: warning: initializing 'shared strict int *' with an expression of type 'shared void *' discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
  strict shared int *p = upc_alloc (5);
                     ^   ~~~~~~~~~~~~~
t.upc:10:22: warning: initializing 'shared strict int *' with an expression of type 'shared int *' discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
  strict shared int *a = s;

The same warning is being produced if I place "#pragama upc strict" at the top of the program or I include upc_strict.h.

swatanabe commented 10 years ago

On 02/05/2014 08:19 PM, Nenad Vukicevic wrote:

The following code produces warnings:

shared int *s;
int
main ()
{
  strict shared int *p = upc_alloc (5);
  strict shared int *a = s;
}
$ ../../bld/bin/clangupc -c t.upc
t.upc:9:22: warning: initializing 'shared strict int *' with an expression of type 'shared void *' discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
  strict shared int *p = upc_alloc (5);
                     ^   ~~~~~~~~~~~~~

Why is this a problem?

The same warning is being produced if I place "#pragama upc strict" at the top of the program or I include upc_strict.h.

pragma upc strict is not relevant, because

it affects accesses, not the pointers.

gary-funck commented 10 years ago

Given that upc_alloc is defined (in upc.h) as follows:

extern shared void *upc_alloc (size_t);

Where/how are qualifiers 'discarded' when going from "shared void " to "strict shared int "?