* Bootstrap with -Wmissing-prototypes doesn't work for C++
@ 2011-08-19 16:36 H.J. Lu
2011-08-19 19:25 ` Joe Buck
0 siblings, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2011-08-19 16:36 UTC (permalink / raw)
To: GCC Development
Since -Wmissing-prototypes doesn't work for C++, using
C++ to bootstrap GCC makes -Wmissing-prototypes useless.
You will see the -Wmissing-prototypes message in stage 1,
but you won't see it in stage3 2/3.
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 16:36 Bootstrap with -Wmissing-prototypes doesn't work for C++ H.J. Lu
@ 2011-08-19 19:25 ` Joe Buck
2011-08-19 19:34 ` H.J. Lu
2011-08-19 21:47 ` Marc Glisse
0 siblings, 2 replies; 13+ messages in thread
From: Joe Buck @ 2011-08-19 19:25 UTC (permalink / raw)
To: H.J. Lu, GCC Development
I'm confused. Since C++ treats the lack of a prototype as a hard error, what does it mean to make -Wmissing-prototypes useless?
________________________________________
From: gcc-owner@gcc.gnu.org [gcc-owner@gcc.gnu.org] On Behalf Of H.J. Lu [hjl.tools@gmail.com]
Sent: Friday, August 19, 2011 9:36 AM
To: GCC Development
Subject: Bootstrap with -Wmissing-prototypes doesn't work for C++
Since -Wmissing-prototypes doesn't work for C++, using
C++ to bootstrap GCC makes -Wmissing-prototypes useless.
You will see the -Wmissing-prototypes message in stage 1,
but you won't see it in stage3 2/3.
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 19:25 ` Joe Buck
@ 2011-08-19 19:34 ` H.J. Lu
2011-08-19 20:35 ` Paul_Koning
2011-08-19 21:45 ` Ian Lance Taylor
2011-08-19 21:47 ` Marc Glisse
1 sibling, 2 replies; 13+ messages in thread
From: H.J. Lu @ 2011-08-19 19:34 UTC (permalink / raw)
To: Joe Buck; +Cc: GCC Development
[hjl@gnu-33 gcc]$ cat x.c
int
foo (int x)
{
return x;
}
[hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
x.c:2:1: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
[hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid
for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
[hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
[hjl@gnu-33 gcc]$
Is this a bug?
On Fri, Aug 19, 2011 at 12:24 PM, Joe Buck <Joe.Buck@synopsys.com> wrote:
> I'm confused. Since C++ treats the lack of a prototype as a hard error, what does it mean to make -Wmissing-prototypes useless?
>
> ________________________________________
> From: gcc-owner@gcc.gnu.org [gcc-owner@gcc.gnu.org] On Behalf Of H.J. Lu [hjl.tools@gmail.com]
> Sent: Friday, August 19, 2011 9:36 AM
> To: GCC Development
> Subject: Bootstrap with -Wmissing-prototypes doesn't work for C++
>
> Since -Wmissing-prototypes doesn't work for C++, using
> C++ to bootstrap GCC makes -Wmissing-prototypes useless.
> You will see the -Wmissing-prototypes message in stage 1,
> but you won't see it in stage3 2/3.
>
> --
> H.J.
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 19:34 ` H.J. Lu
@ 2011-08-19 20:35 ` Paul_Koning
2011-08-19 20:42 ` H.J. Lu
2011-08-19 21:45 ` Ian Lance Taylor
1 sibling, 1 reply; 13+ messages in thread
From: Paul_Koning @ 2011-08-19 20:35 UTC (permalink / raw)
To: hjl.tools, Joe.Buck; +Cc: gcc
I think the point is that the effect of -Wmissing-prototypes is always enabled in C++, so that switch is rejected. The solution would seem to be to remove that switch from the command line if C++ is used to build; that will produce the intended result.
paul
-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of H.J. Lu
Sent: Friday, August 19, 2011 3:34 PM
To: Joe Buck
Cc: GCC Development
Subject: Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
[hjl@gnu-33 gcc]$ cat x.c
int
foo (int x)
{
return x;
}
[hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
x.c:2:1: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
[hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
cc1plus: warning: command line option '-Wmissing-prototypes' is valid for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
[hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
[hjl@gnu-33 gcc]$
Is this a bug?
On Fri, Aug 19, 2011 at 12:24 PM, Joe Buck <Joe.Buck@synopsys.com> wrote:
> I'm confused. Since C++ treats the lack of a prototype as a hard error, what does it mean to make -Wmissing-prototypes useless?
>
> ________________________________________
> From: gcc-owner@gcc.gnu.org [gcc-owner@gcc.gnu.org] On Behalf Of H.J.
> Lu [hjl.tools@gmail.com]
> Sent: Friday, August 19, 2011 9:36 AM
> To: GCC Development
> Subject: Bootstrap with -Wmissing-prototypes doesn't work for C++
>
> Since -Wmissing-prototypes doesn't work for C++, using
> C++ to bootstrap GCC makes -Wmissing-prototypes useless.
> You will see the -Wmissing-prototypes message in stage 1, but you
> won't see it in stage3 2/3.
>
> --
> H.J.
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 20:35 ` Paul_Koning
@ 2011-08-19 20:42 ` H.J. Lu
0 siblings, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2011-08-19 20:42 UTC (permalink / raw)
To: Paul_Koning; +Cc: Joe.Buck, gcc
On Fri, Aug 19, 2011 at 1:35 PM, <Paul_Koning@dell.com> wrote:
> I think the point is that the effect of -Wmissing-prototypes is always enabled in C++, so that switch is rejected. The solution would seem to be to remove that switch from the command line if C++ is used to build; that will produce the intended result.
G++ doesn't give a warning at all:
[hjl@gnu-33 gcc]$ cat x.c
int
foo (int x)
{
return x;
}
[hjl@gnu-33 gcc]$ ./g++ -B./ -Wall -S -O x.c
[hjl@gnu-33 gcc]$
> paul
>
> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of H.J. Lu
> Sent: Friday, August 19, 2011 3:34 PM
> To: Joe Buck
> Cc: GCC Development
> Subject: Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
>
> [hjl@gnu-33 gcc]$ cat x.c
> int
> foo (int x)
> {
> return x;
> }
> [hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
> x.c:2:1: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
> cc1plus: warning: command line option '-Wmissing-prototypes' is valid for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
> [hjl@gnu-33 gcc]$
>
> Is this a bug?
>
> On Fri, Aug 19, 2011 at 12:24 PM, Joe Buck <Joe.Buck@synopsys.com> wrote:
>> I'm confused. Since C++ treats the lack of a prototype as a hard error, what does it mean to make -Wmissing-prototypes useless?
>>
>> ________________________________________
>> From: gcc-owner@gcc.gnu.org [gcc-owner@gcc.gnu.org] On Behalf Of H.J.
>> Lu [hjl.tools@gmail.com]
>> Sent: Friday, August 19, 2011 9:36 AM
>> To: GCC Development
>> Subject: Bootstrap with -Wmissing-prototypes doesn't work for C++
>>
>> Since -Wmissing-prototypes doesn't work for C++, using
>> C++ to bootstrap GCC makes -Wmissing-prototypes useless.
>> You will see the -Wmissing-prototypes message in stage 1, but you
>> won't see it in stage3 2/3.
>>
>> --
>> H.J.
>
>
>
> --
> H.J.
>
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 19:34 ` H.J. Lu
2011-08-19 20:35 ` Paul_Koning
@ 2011-08-19 21:45 ` Ian Lance Taylor
2011-08-19 21:58 ` H.J. Lu
2011-08-19 22:43 ` Gabriel Dos Reis
1 sibling, 2 replies; 13+ messages in thread
From: Ian Lance Taylor @ 2011-08-19 21:45 UTC (permalink / raw)
To: H.J. Lu; +Cc: Joe Buck, GCC Development
"H.J. Lu" <hjl.tools@gmail.com> writes:
> [hjl@gnu-33 gcc]$ cat x.c
> int
> foo (int x)
> {
> return x;
> }
> [hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
> x.c:2:1: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
> cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid
> for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
> [hjl@gnu-33 gcc]$
>
> Is this a bug?
This is a minor missing feature, yes. We ought to implement
-Wmissing-prototypes for C++.
Ian
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 19:25 ` Joe Buck
2011-08-19 19:34 ` H.J. Lu
@ 2011-08-19 21:47 ` Marc Glisse
1 sibling, 0 replies; 13+ messages in thread
From: Marc Glisse @ 2011-08-19 21:47 UTC (permalink / raw)
To: Joe Buck; +Cc: GCC Development, H.J. Lu
On Fri, 19 Aug 2011, Joe Buck wrote:
> I'm confused. Since C++ treats the lack of a prototype as a hard error,
> what does it mean to make -Wmissing-prototypes useless?
-Wmissing-prototype looks very similar to -Wmissing-declarations (which is
supported in C++ but documented as C/objC only). It requires that you
first have:
int f(int);
and only then:
int f(int){return 0;}
--
Marc Glisse
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 21:45 ` Ian Lance Taylor
@ 2011-08-19 21:58 ` H.J. Lu
2011-08-19 22:43 ` Gabriel Dos Reis
1 sibling, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2011-08-19 21:58 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Joe Buck, GCC Development
On Fri, Aug 19, 2011 at 2:45 PM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> [hjl@gnu-33 gcc]$ cat x.c
>> int
>> foo (int x)
>> {
>> return x;
>> }
>> [hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
>> x.c:2:1: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
>> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
>> cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid
>> for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
>> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
>> [hjl@gnu-33 gcc]$
>>
>> Is this a bug?
>
> This is a minor missing feature, yes. We ought to implement
> -Wmissing-prototypes for C++.
>
I opened:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50134
--
H.J.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 21:45 ` Ian Lance Taylor
2011-08-19 21:58 ` H.J. Lu
@ 2011-08-19 22:43 ` Gabriel Dos Reis
2011-08-20 4:18 ` Ian Lance Taylor
1 sibling, 1 reply; 13+ messages in thread
From: Gabriel Dos Reis @ 2011-08-19 22:43 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: H.J. Lu, Joe Buck, GCC Development
On Fri, Aug 19, 2011 at 4:45 PM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> [hjl@gnu-33 gcc]$ cat x.c
>> int
>> foo (int x)
>> {
>> return x;
>> }
>> [hjl@gnu-33 gcc]$ ./xgcc -B./ -S -O -Wmissing-prototypes x.c
>> x.c:2:1: warning: no previous prototype for ‘foo’ [-Wmissing-prototypes]
>> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O -Wmissing-prototypes x.c
>> cc1plus: warning: command line option ‘-Wmissing-prototypes’ is valid
>> for Ada/AdaWhy/C/ObjC but not for C++ [enabled by default]
>> [hjl@gnu-33 gcc]$ ./g++ -B./ -S -O x.c
>> [hjl@gnu-33 gcc]$
>>
>> Is this a bug?
>
> This is a minor missing feature, yes. We ought to implement
> -Wmissing-prototypes for C++.
>
what would it do? There is no notion of `prototype' in C++ (as C
programmers understand it).
So, what would it mean to warn about something we can't take the
negation of? ;-)
-- Gaby
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-19 22:43 ` Gabriel Dos Reis
@ 2011-08-20 4:18 ` Ian Lance Taylor
2011-08-20 5:20 ` Gabriel Dos Reis
0 siblings, 1 reply; 13+ messages in thread
From: Ian Lance Taylor @ 2011-08-20 4:18 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: H.J. Lu, Joe Buck, GCC Development
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> what would it do? There is no notion of `prototype' in C++ (as C
> programmers understand it).
> So, what would it mean to warn about something we can't take the
> negation of? ;-)
-Wmissing-prototypes means that if the compiler sees a globally visible
function definition, it warns if no previous definition of the function
was seen. This is a way of ensuring that the file which defines a
function #includes the header file which declares the function, thus
ensuring that the definition matches the declaration. Although the name
is wrong for C++, the option is meaningful for C++ just as it is for C.
(I actually sent a patch implementing this option to RMS back when I was
first starting to work with gcc, although I think he rewrote it.)
Ian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-20 4:18 ` Ian Lance Taylor
@ 2011-08-20 5:20 ` Gabriel Dos Reis
2011-08-20 14:21 ` Ian Lance Taylor
0 siblings, 1 reply; 13+ messages in thread
From: Gabriel Dos Reis @ 2011-08-20 5:20 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: H.J. Lu, Joe Buck, GCC Development
On Fri, Aug 19, 2011 at 11:17 PM, Ian Lance Taylor <iant@google.com> wrote:
> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>
>> what would it do? There is no notion of `prototype' in C++ (as C
>> programmers understand it).
>> So, what would it mean to warn about something we can't take the
>> negation of? ;-)
>
> -Wmissing-prototypes means that if the compiler sees a globally visible
> function definition, it warns if no previous definition of the function
> was seen. This is a way of ensuring that the file which defines a
> function #includes the header file which declares the function, thus
> ensuring that the definition matches the declaration. Although the name
> is wrong for C++, the option is meaningful for C++ just as it is for C.
So that is -Wmissing-declaration if I understand correctly?
By "globally visible function definition" do you also include member functions?
That would be unusual. I am also concerned that it would mean that a
non-member inline function would have to be declared first, as that is
not the case for
colloquial C++.
I understand what the `prototype' notion is immensely useful in C. But the
problem it was designed to help mitigate has been cured long in C++, and I worry
that trying to placate that to modern C++ would lead to non-colloquial C++.
>
> (I actually sent a patch implementing this option to RMS back when I was
> first starting to work with gcc, although I think he rewrote it.)
>
> Ian
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-20 5:20 ` Gabriel Dos Reis
@ 2011-08-20 14:21 ` Ian Lance Taylor
2011-08-21 23:48 ` Joe Buck
0 siblings, 1 reply; 13+ messages in thread
From: Ian Lance Taylor @ 2011-08-20 14:21 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: H.J. Lu, Joe Buck, GCC Development
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> On Fri, Aug 19, 2011 at 11:17 PM, Ian Lance Taylor <iant@google.com> wrote:
>> Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
>>
>>> what would it do? There is no notion of `prototype' in C++ (as C
>>> programmers understand it).
>>> So, what would it mean to warn about something we can't take the
>>> negation of? ;-)
>>
>> -Wmissing-prototypes means that if the compiler sees a globally visible
>> function definition, it warns if no previous definition of the function
>> was seen. This is a way of ensuring that the file which defines a
>> function #includes the header file which declares the function, thus
>> ensuring that the definition matches the declaration. Although the name
>> is wrong for C++, the option is meaningful for C++ just as it is for C.
>
> So that is -Wmissing-declaration if I understand correctly?
Hmmm, you're right, -Wmissing-declarations seems to be equivalent to
-Wmissing-prototypes when using C++. Sorry I missed that.
Ian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Bootstrap with -Wmissing-prototypes doesn't work for C++
2011-08-20 14:21 ` Ian Lance Taylor
@ 2011-08-21 23:48 ` Joe Buck
0 siblings, 0 replies; 13+ messages in thread
From: Joe Buck @ 2011-08-21 23:48 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Gabriel Dos Reis, H.J. Lu, GCC Development
On Sat, Aug 20, 2011 at 07:20:41AM -0700, Ian Lance Taylor wrote:
> Hmmm, you're right, -Wmissing-declarations seems to be equivalent to
> -Wmissing-prototypes when using C++. Sorry I missed that.
Then it would seem that HJ's issue could be fixed by treating
-Wmissing-prototypes as a synonym for -Wmissing-declarations when building
C++.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-08-21 23:48 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19 16:36 Bootstrap with -Wmissing-prototypes doesn't work for C++ H.J. Lu
2011-08-19 19:25 ` Joe Buck
2011-08-19 19:34 ` H.J. Lu
2011-08-19 20:35 ` Paul_Koning
2011-08-19 20:42 ` H.J. Lu
2011-08-19 21:45 ` Ian Lance Taylor
2011-08-19 21:58 ` H.J. Lu
2011-08-19 22:43 ` Gabriel Dos Reis
2011-08-20 4:18 ` Ian Lance Taylor
2011-08-20 5:20 ` Gabriel Dos Reis
2011-08-20 14:21 ` Ian Lance Taylor
2011-08-21 23:48 ` Joe Buck
2011-08-19 21:47 ` Marc Glisse
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).