public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28774]  New: Request for warning where const/volatile is ignored in a cast
@ 2006-08-18 18:02 simon_baldwin at yahoo dot com
  2006-08-24  1:59 ` [Bug c++/28774] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: simon_baldwin at yahoo dot com @ 2006-08-18 18:02 UTC (permalink / raw)
  To: gcc-bugs

In the code fragment

  int i = static_cast<const int>(1.234);
  int j = static_cast<volatile int>(1.234);

the const and volatile qualifiers in the cast are silently ignored, even with
-Wall -W -pedantic.  A warning from g++ for this mild infraction would be
useful.


-- 
           Summary: Request for warning where const/volatile is ignored in a
                    cast
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: simon_baldwin at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
@ 2006-08-24  1:59 ` bangerth at dealii dot org
  2006-08-24 16:53 ` simon_baldwin at yahoo dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2006-08-24  1:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2006-08-24 01:59 -------
Um, why? The value "1.234" is an rvalue of type double. You cast it to
an rvalue of type "const int", which can clearly be assigned to an
int right away without another cast. In fact, const-volatile qualifications
do not have meaning for rvalues at all, which makes the whole question
kinda moot. 

Or do I miss something?

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
  2006-08-24  1:59 ` [Bug c++/28774] " bangerth at dealii dot org
@ 2006-08-24 16:53 ` simon_baldwin at yahoo dot com
  2006-08-27  5:04 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simon_baldwin at yahoo dot com @ 2006-08-24 16:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from simon_baldwin at yahoo dot com  2006-08-24 16:53 -------
You didn't miss anything.  There's no bug here, just a request for a new
warning message.

As you note, the const-volatile qualifications in the cast have no meaning, and
are completely ignored by the compiler.  While it's busy ignoring them, it
could note this as a warning, in case the code author really meant something
different.

icc warns here; this PR aims to improve agreement in warnings between g++ and
icc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
  2006-08-24  1:59 ` [Bug c++/28774] " bangerth at dealii dot org
  2006-08-24 16:53 ` simon_baldwin at yahoo dot com
@ 2006-08-27  5:04 ` pinskia at gcc dot gnu dot org
  2006-08-27  6:44 ` ian at airs dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-27  5:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-08-27 05:03 -------
(In reply to comment #2)
> icc warns here; this PR aims to improve agreement in warnings between g++ and
> icc.
> 

HUH? Why do you want that?  GCC warns in more places than ICC will ever warn. 
To me this is an useless warning and in fact goes against what is questionable
even to a standards guy.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
                   ` (2 preceding siblings ...)
  2006-08-27  5:04 ` pinskia at gcc dot gnu dot org
@ 2006-08-27  6:44 ` ian at airs dot com
  2007-01-23 14:35 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ian at airs dot com @ 2006-08-27  6:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ian at airs dot com  2006-08-27 06:44 -------
I disagree.  It is always useful to optionally warn about meaningless code.  It
can be a way to find a real bug in the program.  It is not conceptually
different from existing warnings like -Wredundant-decls.  The code works fine,
but something is odd.

The behaviour of icc is irrelevant here.  If you want to close this again,
please give a reason why we should not warn about meaningless code.


-- 

ian at airs dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
                   ` (3 preceding siblings ...)
  2006-08-27  6:44 ` ian at airs dot com
@ 2007-01-23 14:35 ` manu at gcc dot gnu dot org
  2007-03-12 12:10 ` manu at gcc dot gnu dot org
  2007-03-12 21:48 ` simon_baldwin at yahoo dot com
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-23 14:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2007-01-23 14:35 -------
We already have a warning about discarding qualifiers somewhere. Perhaps we
could just add this to that one (saving us from yet another warning option).


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
                   ` (4 preceding siblings ...)
  2007-01-23 14:35 ` manu at gcc dot gnu dot org
@ 2007-03-12 12:10 ` manu at gcc dot gnu dot org
  2007-03-12 21:48 ` simon_baldwin at yahoo dot com
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-12 12:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from manu at gcc dot gnu dot org  2007-03-12 12:10 -------
This seems a duplicate of PR 14710.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/28774] Request for warning where const/volatile is ignored in a cast
  2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
                   ` (5 preceding siblings ...)
  2007-03-12 12:10 ` manu at gcc dot gnu dot org
@ 2007-03-12 21:48 ` simon_baldwin at yahoo dot com
  6 siblings, 0 replies; 8+ messages in thread
From: simon_baldwin at yahoo dot com @ 2007-03-12 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from simon_baldwin at yahoo dot com  2007-03-12 21:48 -------
PR 14710 isn't really quite the same thing as PR 28774.  PR 14170 is concerned
with unnecessary casts; PR 28774 is concerned with unnecessary "const" or
"volatile" qualifiers within otherwise valid and perhaps necessary casts.

That said, this PR really isn't all that useful, is tiny, and hasn't received a
lot of support, so I'm going to withdraw it (by setting resolution to
"WONTFIX", which I hope will do the right thing).


-- 

simon_baldwin at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28774


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-12 21:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-18 18:02 [Bug c++/28774] New: Request for warning where const/volatile is ignored in a cast simon_baldwin at yahoo dot com
2006-08-24  1:59 ` [Bug c++/28774] " bangerth at dealii dot org
2006-08-24 16:53 ` simon_baldwin at yahoo dot com
2006-08-27  5:04 ` pinskia at gcc dot gnu dot org
2006-08-27  6:44 ` ian at airs dot com
2007-01-23 14:35 ` manu at gcc dot gnu dot org
2007-03-12 12:10 ` manu at gcc dot gnu dot org
2007-03-12 21:48 ` simon_baldwin at yahoo dot com

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).