public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24983]  New: Needs a warning?
@ 2005-11-22  2:31 igodard at pacbell dot net
  2005-11-22  2:46 ` [Bug c++/24983] " gdr at integrable-solutions dot net
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2005-11-22  2:31 UTC (permalink / raw)
  To: gcc-bugs

struct foo { const void f(); };
void foo::f(){}

gets you:

~/ootbc/members/src$ g++ foo.cc -Wall
foo.cc:2: error: prototype for `void foo::f()' does not match any in class
`foo'
foo.cc:1: error: candidate is: const void foo::f()
foo.cc:2: error: `void foo::f()' and `const void foo::f()' cannot be overloaded

Comeau gives a warning on the declaration and one error (not two) on the
definition.


-- 
           Summary: Needs a warning?
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
@ 2005-11-22  2:46 ` gdr at integrable-solutions dot net
  2005-11-22  3:01 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-22  2:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from gdr at integrable-solutions dot net  2005-11-22 02:46 -------
Subject: Re:   New: Needs a warning?

"igodard at pacbell dot net" <gcc-bugzilla@gcc.gnu.org> writes:

| struct foo { const void f(); };
| void foo::f(){}
| 
| gets you:
| 
| ~/ootbc/members/src$ g++ foo.cc -Wall
| foo.cc:2: error: prototype for `void foo::f()' does not match any in class
| `foo'
| foo.cc:1: error: candidate is: const void foo::f()
| foo.cc:2: error: `void foo::f()' and `const void foo::f()' cannot be
overloaded

Awful.  Please assign it to me.

-- Gaby


-- 


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
  2005-11-22  2:46 ` [Bug c++/24983] " gdr at integrable-solutions dot net
@ 2005-11-22  3:01 ` pinskia at gcc dot gnu dot org
  2005-11-22  3:58   ` Gabriel Dos Reis
  2005-11-22  3:45 ` igodard at pacbell dot net
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-22  3:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-11-22 03:01 -------
Different versions give different diagnostics:
earth:~>gcc t.cc
t.cc:2: error: prototype for 'void foo::f()' does not match any in class 'foo'
t.cc:1: error: candidate is: const void foo::f()
t.cc:2: error: 'void foo::f()' cannot be overloaded
t.cc:1: error: with 'const void foo::f()'
earth:~>~/ia32_linux_gcc3_4/bin/gcc t.cc
t.cc:2: error: prototype for `void foo::f()' does not match any in class `foo'
t.cc:1: error: candidate is: const void foo::f()
t.cc:2: error: `void foo::f()' and `const void foo::f()' cannot be overloaded
earth:~>~/ia32_linux_gcc3_3/bin/gcc t.cc
t.cc:2: error: prototype for `void foo::f()' does not match any in class `foo'
t.cc:1: error: candidate is: const void foo::f()
t.cc:2: error: `void foo::f()' and `const void foo::f()' cannot be overloaded
earth:~>~/ia32_linux_gcc3_2/bin/gcc t.cc
t.cc:2: prototype for `void foo::f()' does not match any in class `foo'
t.cc:1: candidate is: const void foo::f()
t.cc:2: `void foo::f()' and `const void foo::f()' cannot be overloaded
earth:~>~/ia32_linux_gcc3_0/bin/gcc t.cc
t.cc:2: prototype for `void foo::f()' does not match any in class `foo'
t.cc:1: candidate is: const void foo::f()
earth:~>~/ia32_linux_gcc2_95//bin/gcc t.cc
t.cc:2: new declaration `void foo::f()'
t.cc:1: ambiguates old declaration `const void foo::f()'


I say that 3.0.x is the best if it is what we should say then we have a
regression.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
  2005-11-22  2:46 ` [Bug c++/24983] " gdr at integrable-solutions dot net
  2005-11-22  3:01 ` pinskia at gcc dot gnu dot org
@ 2005-11-22  3:45 ` igodard at pacbell dot net
  2005-11-22  3:58 ` gdr at integrable-solutions dot net
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2005-11-22  3:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from igodard at pacbell dot net  2005-11-22 03:45 -------
The 3.0 is the best error, but I like the warning that comeau also gives:

Comeau C/C++ 4.3.3 (Aug  6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing.  All rights reserved.
MODE:strict errors C++

"ComeauTest.c", line 1: warning: type qualifier on return type is meaningless
  struct foo { const void f(); };
                          ^

"ComeauTest.c", line 2: error: declaration is incompatible with
          "const void foo::f()" (declared at line 1)
  void foo::f(){}
            ^

1 error detected in the compilation of "ComeauTest.c".


-- 


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2005-11-22  3:45 ` igodard at pacbell dot net
@ 2005-11-22  3:58 ` gdr at integrable-solutions dot net
  2005-11-22  4:05 ` igodard at pacbell dot net
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-22  3:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from gdr at integrable-solutions dot net  2005-11-22 03:58 -------
Subject: Re:  Needs a warning?

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| earth:~>~/ia32_linux_gcc3_0/bin/gcc t.cc
| t.cc:2: prototype for `void foo::f()' does not match any in class `foo'
| t.cc:1: candidate is: const void foo::f()
| earth:~>~/ia32_linux_gcc2_95//bin/gcc t.cc
| t.cc:2: new declaration `void foo::f()'
| t.cc:1: ambiguates old declaration `const void foo::f()'
| 
| 
| I say that 3.0.x is the best if it is what we should say then we have a
| regression.

We should say: 'const void' is not a valid type
and be done with it.

-- Gaby


-- 


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


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

* Re: [Bug c++/24983] Needs a warning?
  2005-11-22  3:01 ` pinskia at gcc dot gnu dot org
@ 2005-11-22  3:58   ` Gabriel Dos Reis
  0 siblings, 0 replies; 9+ messages in thread
From: Gabriel Dos Reis @ 2005-11-22  3:58 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| earth:~>~/ia32_linux_gcc3_0/bin/gcc t.cc
| t.cc:2: prototype for `void foo::f()' does not match any in class `foo'
| t.cc:1: candidate is: const void foo::f()
| earth:~>~/ia32_linux_gcc2_95//bin/gcc t.cc
| t.cc:2: new declaration `void foo::f()'
| t.cc:1: ambiguates old declaration `const void foo::f()'
| 
| 
| I say that 3.0.x is the best if it is what we should say then we have a
| regression.

We should say: 'const void' is not a valid type
and be done with it.

-- Gaby


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2005-11-22  3:58 ` gdr at integrable-solutions dot net
@ 2005-11-22  4:05 ` igodard at pacbell dot net
  2005-11-23  5:25 ` bangerth at dealii dot org
  2008-03-30 20:45 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2005-11-22  4:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from igodard at pacbell dot net  2005-11-22 04:05 -------
On the contrary, "const void" is a valid type, because the difference between
"const void*" and "void*" preserved the typeless constness, which can be
important in disambiguating templates. So if "const void" is valid as a pointer
target, it is also (syntactically) valid as a function return type. It's just
not meaningful, so EDG gives a warning. 

Note that the gcc diagnostic is the same if the return type is int/const int,
so it's nothing to do with "void".

Ivan


-- 


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2005-11-22  4:05 ` igodard at pacbell dot net
@ 2005-11-23  5:25 ` bangerth at dealii dot org
  2008-03-30 20:45 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-11-23  5:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from bangerth at dealii dot org  2005-11-23 05:25 -------
Given the literal meaning of the word "void", it is amusing to think
about what one might want to mean when one says "const void"...


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-23 05:25:17
               date|                            |


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


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

* [Bug c++/24983] Needs a warning?
  2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
                   ` (5 preceding siblings ...)
  2005-11-23  5:25 ` bangerth at dealii dot org
@ 2008-03-30 20:45 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-03-30 20:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2008-03-30 20:45 -------
With -Wextra (aka -W), we get a warning now:
t.cc:1: warning: type qualifiers ignored on function return type


So closing as fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2008-03-30 20:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-22  2:31 [Bug c++/24983] New: Needs a warning? igodard at pacbell dot net
2005-11-22  2:46 ` [Bug c++/24983] " gdr at integrable-solutions dot net
2005-11-22  3:01 ` pinskia at gcc dot gnu dot org
2005-11-22  3:58   ` Gabriel Dos Reis
2005-11-22  3:45 ` igodard at pacbell dot net
2005-11-22  3:58 ` gdr at integrable-solutions dot net
2005-11-22  4:05 ` igodard at pacbell dot net
2005-11-23  5:25 ` bangerth at dealii dot org
2008-03-30 20:45 ` pinskia at gcc dot gnu dot org

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