public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17654] New: Pointless warning on incompatible pointer types
@ 2004-09-24 15:16 jbeulich at novell dot com
  2004-09-24 15:51 ` [Bug c/17654] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jbeulich at novell dot com @ 2004-09-24 15:16 UTC (permalink / raw)
  To: gcc-bugs

While being in line with the standard, there does not seem to be any point in
emitting a warning when passing a multi-level pointer not const-qualified at
some level to a function the parameter of which is an equivalent pointer, just
const-qualified at all levels:

void test2(const char*const*);

void test(char**ppc) {
	test2(ppc);
}

Without such functionality, it is for certain constructs, rather hard to achieve
const-correct, warning-free code that does also not use ill casts.

-- 
           Summary: Pointless warning on incompatible pointer types
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbeulich at novell dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
@ 2004-09-24 15:51 ` pinskia at gcc dot gnu dot org
  2004-09-27  7:50 ` jbeulich at novell dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-24 15:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-24 15:51 -------
The warnings are correct.

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


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
  2004-09-24 15:51 ` [Bug c/17654] " pinskia at gcc dot gnu dot org
@ 2004-09-27  7:50 ` jbeulich at novell dot com
  2004-09-27 13:39 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jbeulich at novell dot com @ 2004-09-27  7:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbeulich at novell dot com  2004-09-27 07:50 -------
I said so in the original report. Nevertheless they appear to be pointless and
restricting from writing clean code, which is why I filed this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
  2004-09-24 15:51 ` [Bug c/17654] " pinskia at gcc dot gnu dot org
  2004-09-27  7:50 ` jbeulich at novell dot com
@ 2004-09-27 13:39 ` pinskia at gcc dot gnu dot org
  2004-09-27 15:14 ` jbeulich at novell dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-27 13:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-27 13:39 -------
Again this correct to the standard, why do you think otherwise (-pednatic-errors errors out).

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


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (2 preceding siblings ...)
  2004-09-27 13:39 ` pinskia at gcc dot gnu dot org
@ 2004-09-27 15:14 ` jbeulich at novell dot com
  2004-09-27 15:24 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jbeulich at novell dot com @ 2004-09-27 15:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbeulich at novell dot com  2004-09-27 15:14 -------
Perhaps giving not just the sample, but a more complete example helps: Consider
having a structure with a field being a head of a linked list (of pointer type).
There are functions which may modify this list, and others which only traverse
it. Further consider that proper locking has to be done prior to accessing the
list head. If this locking is to be done inside the manipulating functions (as I
would always try to do), the the callers of these functions will have to pass
the address of the structure member (i.e. a pointer to a pointer). Now, since
there are cases where I have to pass pointers to non-const, the structure field
itself can neither itself be const nor be a pointer to const. However, for those
functions that don't modify the list, const-correct programming calls for a
parameter declaration with all levels being const modified. With the current
(standard conforming) warning, this is not possible in a program that e.g. uses
-Werror.
Thus I continue to believe that this is an omission on the part of the standard,
and would hence want to see gcc provide at least an optional way to circumvent
this problem.

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


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (3 preceding siblings ...)
  2004-09-27 15:14 ` jbeulich at novell dot com
@ 2004-09-27 15:24 ` bangerth at dealii dot org
  2004-09-27 15:32 ` jsm at polyomino dot org dot uk
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-09-27 15:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-09-27 15:24 -------
My understanding is that if the compiler doesn't disallow this, then there 
are ways to "cast away" a const specifier by doing a number of conversions 
such as you propose. I don't recall the details, however, so this may sound 
very nebulous... 
 
W. 

-- 


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (5 preceding siblings ...)
  2004-09-27 15:32 ` jsm at polyomino dot org dot uk
@ 2004-09-27 15:32 ` jbeulich at novell dot com
  2004-09-27 15:50 ` pinskia at gcc dot gnu dot org
  2004-09-27 15:50 ` schwab at suse dot de
  8 siblings, 0 replies; 10+ messages in thread
From: jbeulich at novell dot com @ 2004-09-27 15:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbeulich at novell dot com  2004-09-27 15:32 -------
This can only happen when any of the levels is not const-qualified. When all
levels are, you can't achieve such results.

-- 


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (4 preceding siblings ...)
  2004-09-27 15:24 ` bangerth at dealii dot org
@ 2004-09-27 15:32 ` jsm at polyomino dot org dot uk
  2004-09-27 15:32 ` jbeulich at novell dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-09-27 15:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-09-27 15:32 -------
Subject: Re:  Pointless warning on incompatible pointer types

On Mon, 27 Sep 2004, jbeulich at novell dot com wrote:

> Thus I continue to believe that this is an omission on the part of the standard,
> and would hence want to see gcc provide at least an optional way to circumvent
> this problem.

That way at present is to use the C++ compiler, if you want the C++ 
const-correctness rules.  Such a change was proposed for C99 in 
<http://www.open-std.org/JTC1/SC22/WG14/www/docs/n754.htm>.  I do not know 
why it was not adopted although the impression I get is that it was 
proposed too late in the process and there wasn't enough time at the 
relevant meeting.  I would suggest it might be worth proposing such a 
change again when features for C1x are under consideration in some years' 
time; C++ provides the prior art.



-- 


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (7 preceding siblings ...)
  2004-09-27 15:50 ` pinskia at gcc dot gnu dot org
@ 2004-09-27 15:50 ` schwab at suse dot de
  8 siblings, 0 replies; 10+ messages in thread
From: schwab at suse dot de @ 2004-09-27 15:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-09-27 15:50 -------
If you want C++ you know where to find it. :-) 

-- 


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


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

* [Bug c/17654] Pointless warning on incompatible pointer types
  2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
                   ` (6 preceding siblings ...)
  2004-09-27 15:32 ` jbeulich at novell dot com
@ 2004-09-27 15:50 ` pinskia at gcc dot gnu dot org
  2004-09-27 15:50 ` schwab at suse dot de
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-27 15:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-27 15:50 -------
So it is still not a bug in the current compiler at all because C99 says one thing but C++ says another.

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


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


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

end of thread, other threads:[~2004-09-27 15:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24 15:16 [Bug c/17654] New: Pointless warning on incompatible pointer types jbeulich at novell dot com
2004-09-24 15:51 ` [Bug c/17654] " pinskia at gcc dot gnu dot org
2004-09-27  7:50 ` jbeulich at novell dot com
2004-09-27 13:39 ` pinskia at gcc dot gnu dot org
2004-09-27 15:14 ` jbeulich at novell dot com
2004-09-27 15:24 ` bangerth at dealii dot org
2004-09-27 15:32 ` jsm at polyomino dot org dot uk
2004-09-27 15:32 ` jbeulich at novell dot com
2004-09-27 15:50 ` pinskia at gcc dot gnu dot org
2004-09-27 15:50 ` schwab at suse dot de

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