public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kaveh R. GHAZI" <ghazi@caip.rutgers.edu>
To: Gabriel Dos Reis <gdr@cs.tamu.edu>
Cc: Mark Mitchell <mark@codesourcery.com>,
	        Richard Guenther <richard.guenther@gmail.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH]: Fix problematic -Wcast-qual cases using new CONST_CAST     macro
Date: Mon, 06 Aug 2007 04:42:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.58.0708060018100.3285@caipclassic.rutgers.edu> (raw)
In-Reply-To: <Pine.LNX.4.64.0708051924440.17515@gauss.cs.tamu.edu>

On Sun, 5 Aug 2007, Gabriel Dos Reis wrote:

> On Sun, 5 Aug 2007, Mark Mitchell wrote:
>
> | Gabriel Dos Reis wrote:
> |
> | > | Richard, do you have any remaining objections to this patch?
> | > | http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01993.html
> |
> | I'm not very keen on the use of a union here, just as a way to outwit
> | our own warning machinery.
>
> A good point that the union is overkill.

I used a union because it's the only solution I found that works.  I would
be happy to use something else more elegant if someone suggests something
concrete.


> |  For grep-ability, just using CONST_CAST with
> | a definition that is a traditional C-style cast, would work fine.
>
> The compiler will "see" through the macro expansion and will start
> warning when -Wcast-qual is on.

Right.



> | Or,
> | can we go through an inline function, with warnings disabled on the
> | inline function?


How do we disable warnings on the fly inside an inline function?  Did
someone implement "#pragma nowarn foo" when I wasn't looking?



> I don't know whether this works; Kaveh can you try it?
> (You would still have to write the function name all caps).
> -- Gaby

Sure, but try what exactly?

I attempted various inline function permutations and the only thing that
works is putting a union inside the inline function.  (By "works" I mean
silences -Wcast-qual warning.)  I don't see how putting the union inside
an inline function as any better than using a macro, in fact the inline
function version is slightly worse.  It can't use __typeof() like Richard
suggested because the function prototype hides the arguments actual type.

In light of this, I'd like permission to install my existing patch.  If
someone can suggest a better definition for CONST_CAST() and/or write an
inline function to replace it, it's merely a one-line change to system.h
as a follow-up.  Until then, the union hack is the only thing I can think
of that actually does the job.

Okay?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu

  reply	other threads:[~2007-08-06  4:42 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27  8:15 Kaveh R. GHAZI
2007-07-27  9:53 ` Richard Guenther
2007-07-27 17:24   ` Kaveh R. GHAZI
2007-07-27 19:32     ` Richard Guenther
2007-07-27 19:37       ` Kaveh R. GHAZI
2007-07-27 20:28         ` Gabriel Dos Reis
2007-08-03 14:19         ` Kaveh R. GHAZI
2007-08-03 18:07           ` Gabriel Dos Reis
2007-08-06  0:19             ` Mark Mitchell
2007-08-06  0:32               ` Gabriel Dos Reis
2007-08-06  4:42                 ` Kaveh R. GHAZI [this message]
2007-08-06  5:23                   ` Mark Mitchell
2007-08-06 14:09                     ` Kaveh R. GHAZI
2007-08-06 15:33                       ` Gabriel Dos Reis
2007-08-06 17:59                         ` Kaveh R. GHAZI
2007-08-06 18:11                           ` DJ Delorie
2007-08-06 18:23                             ` Gabriel Dos Reis
2007-08-06 18:18                           ` Gabriel Dos Reis
2007-08-06 15:44                       ` Mark Mitchell
2007-08-08  5:04                         ` Add a __nowarn__ keyword Kaveh R. GHAZI
2007-08-08  8:52                           ` Manuel López-Ibáñez
2007-08-08  9:04                             ` Gabriel Dos Reis
2007-08-08 13:06                               ` Kaveh R. GHAZI
2007-08-08 13:16                                 ` Gabriel Dos Reis
2007-08-08 13:48                                   ` Kaveh R. GHAZI
2007-08-08 13:58                                     ` Paolo Bonzini
2007-08-10  1:42                                       ` Gabriel Dos Reis
2007-08-08 14:29                                     ` Manuel López-Ibáñez
2007-08-08 15:25                                       ` Daniel Jacobowitz
2007-08-08 16:35                                       ` Paolo Bonzini
2007-08-08 19:31                                         ` Kaveh R. GHAZI
2007-08-08 19:42                                           ` Gabriel Dos Reis
2007-08-08 20:22                                             ` Paolo Bonzini
2007-08-08 19:51                                           ` DJ Delorie
2007-08-08 22:41                                             ` Kaveh R. GHAZI
2007-08-08 22:54                                               ` DJ Delorie
2007-08-09  2:36                                                 ` Kaveh R. GHAZI
2007-08-09 13:40                                                   ` Daniel Jacobowitz
2007-08-09 14:19                                                     ` Kaveh R. GHAZI
2007-08-09 14:30                                                       ` Daniel Jacobowitz
2007-08-09 15:05                                                         ` Manuel López-Ibáñez
2007-08-09 15:15                                                           ` Daniel Jacobowitz
2007-08-09 15:31                                                           ` DJ Delorie
2007-08-09 22:23                                                             ` Mark Mitchell
2007-08-09 22:43                                                               ` Kaveh R. GHAZI
2007-08-10  1:52                                                                 ` Gabriel Dos Reis
2007-08-10 16:42                                                                 ` Mark Mitchell
2007-08-10  1:50                                                               ` Gabriel Dos Reis
2007-08-10  2:02                                                                 ` DJ Delorie
2007-08-10  3:09                                                                   ` Gabriel Dos Reis
2007-08-10  3:28                                                                     ` DJ Delorie
2007-08-10  3:44                                                                       ` Gabriel Dos Reis
2007-08-10  4:00                                                                         ` DJ Delorie
2007-08-10  4:12                                                                           ` Gabriel Dos Reis
2007-08-10  4:23                                                                             ` DJ Delorie
2007-08-10 13:24                                                                               ` Gabriel Dos Reis
2007-08-10 18:40                                                                             ` DJ Delorie
2007-08-11 19:19                                                                               ` Joseph S. Myers
2007-08-13 18:36                                                                                 ` DJ Delorie
2007-08-21  3:24                                                                                 ` DJ Delorie
2009-11-21 12:24                                                                                   ` Magnus Fromreide
2009-11-23 16:40                                                                                     ` Manuel López-Ibáñez
2009-11-23 23:28                                                                                     ` DJ Delorie
2007-08-10 19:05                                                                             ` DJ Delorie
2007-08-10 10:04                                                                       ` Manuel López-Ibáñez
2007-08-10 18:46                                                                         ` DJ Delorie
2007-08-09 15:21                                                         ` Kaveh R. GHAZI
2007-08-09 16:48                                                           ` Paolo Bonzini
2007-08-09 20:04                                                   ` Ian Lance Taylor
2007-08-09 20:40                                                     ` DJ Delorie
2007-08-10  1:47                                                   ` Gabriel Dos Reis
2007-08-09 14:41                                           ` Manuel López-Ibáñez
2007-08-09 16:36                                             ` Gabriel Dos Reis
2007-08-09 23:14                                               ` Kaveh R. GHAZI
2007-08-09 22:55                                             ` Kaveh R. GHAZI
2007-08-10  3:18                                               ` Kaveh R. GHAZI
2007-08-10  3:25                                                 ` Gabriel Dos Reis
2007-08-08 12:56                             ` Kaveh R. GHAZI
2007-08-08 14:05                               ` Manuel López-Ibáñez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.58.0708060018100.3285@caipclassic.rutgers.edu \
    --to=ghazi@caip.rutgers.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@cs.tamu.edu \
    --cc=mark@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).