This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix const pointer warning in gthr-win32.h


Kaveh R. Ghazi wrote:
From: "Ian Lance Taylor" <iant@google.com>

"Aaron W. LaFramboise" <aaronavay62@aaronwl.com> writes:

OK, I discovered this file is also used in other places outside of GCC
such as in libgfortran, so using tsystem.h is not OK there.  What is
the  proper way to make this error go away then, as I understand the
union trick is the only way to silence it?

Is it possible to fix (i.e. const-ify) the relevant function prototypes, or do you end up calling a system interface that's non-const and get stuck?

No, the system interface is a void *. And I think that is correct; it should not be const void *; the GTHR is incorrect in wanting it to be a const void *, because __gthread_getspecific is returning void *, and this is the same pointer. If we're returning a non-const pointer from TLS, we need to be saving a non-const pointer, otherwise this doesn't make any sense.


I would try just taking out the 'const' but I think this will break a lot of platforms I have no way of testing. But I suppose I could try anyway and just deal with the breakage.

So I'm not sure what the proper way to resolve this is. Advice?

By the way, I think this prototype is actually incorrect.  The ptr
parameter really should not be const, because __gthread_getspecific
returns a non-const void *.  However, I'm not sure if there's some
other reason this should be const; does anyone know about this?

What code are you compiling when you see this warning? As far as I know code that uses gthr-win32.h is mostly C code which should be compiled with -Wc++-compat.

It comes from anything that includes gthr-win32.h.


I think the warning comes from -Wcast-qual, not -Wc++-compat.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]