public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
@ 2020-05-05  9:42 ` amonakov at gcc dot gnu.org
  2020-05-05 13:24 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2020-05-05  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Another reason to have -Wmissing-declarations is that otherwise mismatches of
unused functions are not caught until it's too late (mismatching definition is
assumed to be an overload of the function declared in the header file).

For a recent example, see
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545129.html which was
necessary after a mismatch introduced in
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545114.html

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
  2020-05-05  9:42 ` [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations amonakov at gcc dot gnu.org
@ 2020-05-05 13:24 ` redi at gcc dot gnu.org
  2020-05-05 13:34 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-05 13:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #0)
> Transition to C++ did not change -Wmissing-prototypes to
> -Wmissing-declarations, so over time several violations crept in. In
> particular this penalizes optimization during non-LTO bootstrap (the
> compiler has to assume the function might be used in another TU, even though
> in reality all uses are in current file and it simply misses the 'static'
> keyword).

Why is it missing the static keyword then? (Or alternatively, why isn't it in
an anonymous namespace?)


(In reply to Alexander Monakov from comment #1)
> Another reason to have -Wmissing-declarations is that otherwise mismatches
> of unused functions are not caught until it's too late (mismatching
> definition is assumed to be an overload of the function declared in the
> header file).

A more robust way to avoid that problem is to declare the function in a
namespace, and define it using a qualified name:

// declaration
namespace targ
{
  void foo(void*);
}

// definition
void targ::foo(class vec_info*);  // ERROR

Because no foo with that signature was declared in namespace targ it's an
error, not just a warning.

Should the coding convention be adjusted to avoid this problem?

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
  2020-05-05  9:42 ` [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations amonakov at gcc dot gnu.org
  2020-05-05 13:24 ` redi at gcc dot gnu.org
@ 2020-05-05 13:34 ` rguenth at gcc dot gnu.org
  2020-05-05 14:01 ` amonakov at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-05 13:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> (In reply to Alexander Monakov from comment #0)
> > Transition to C++ did not change -Wmissing-prototypes to
> > -Wmissing-declarations, so over time several violations crept in. In
> > particular this penalizes optimization during non-LTO bootstrap (the
> > compiler has to assume the function might be used in another TU, even though
> > in reality all uses are in current file and it simply misses the 'static'
> > keyword).
> 
> Why is it missing the static keyword then? (Or alternatively, why isn't it
> in an anonymous namespace?)
> 
> 
> (In reply to Alexander Monakov from comment #1)
> > Another reason to have -Wmissing-declarations is that otherwise mismatches
> > of unused functions are not caught until it's too late (mismatching
> > definition is assumed to be an overload of the function declared in the
> > header file).
> 
> A more robust way to avoid that problem is to declare the function in a
> namespace, and define it using a qualified name:
> 
> // declaration
> namespace targ
> {
>   void foo(void*);
> }
> 
> // definition
> void targ::foo(class vec_info*);  // ERROR
> 
> Because no foo with that signature was declared in namespace targ it's an
> error, not just a warning.
> 
> Should the coding convention be adjusted to avoid this problem?

Ah, I like the namespace thing for target hooks (possibly langhooks as well).

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-05-05 13:34 ` rguenth at gcc dot gnu.org
@ 2020-05-05 14:01 ` amonakov at gcc dot gnu.org
  2020-06-08  1:55 ` egallager at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2020-05-05 14:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
> Why is it missing the static keyword then? (Or alternatively, why isn't it in an anonymous namespace?)

Huh? Without the warning developers may simply forget to put the 'static'
keyword. With the warning they would be reminded when bootstrapping the patch.


> Ah, I like the namespace thing for target hooks (possibly langhooks as well).

Sure, it's nice to have sensible namespace rules for future additions, but
hopefully that's not a reason/excuse to never re-enable the warning.

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-05-05 14:01 ` amonakov at gcc dot gnu.org
@ 2020-06-08  1:55 ` egallager at gcc dot gnu.org
  2021-11-30  7:18 ` egallager at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2020-06-08  1:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #5 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #4)
> > Why is it missing the static keyword then? (Or alternatively, why isn't it in an anonymous namespace?)
> 
> Huh? Without the warning developers may simply forget to put the 'static'
> keyword. With the warning they would be reminded when bootstrapping the
> patch.
> 
> 
> > Ah, I like the namespace thing for target hooks (possibly langhooks as well).
> 
> Sure, it's nice to have sensible namespace rules for future additions, but
> hopefully that's not a reason/excuse to never re-enable the warning.

Agreed; I think I tried enabling the warning once while bootstrapping myself,
but I forget what the results were...

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-06-08  1:55 ` egallager at gcc dot gnu.org
@ 2021-11-30  7:18 ` egallager at gcc dot gnu.org
  2021-11-30 10:38 ` amonakov at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-11-30  7:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
To clarify, are we talking about adding it just in the gcc subdirectory, or any
other subdirectories as well?

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2021-11-30  7:18 ` egallager at gcc dot gnu.org
@ 2021-11-30 10:38 ` amonakov at gcc dot gnu.org
  2021-11-30 11:48 ` egallager at gcc dot gnu.org
  2023-09-10 15:34 ` egallager at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2021-11-30 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

--- Comment #7 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
As I understand, only the gcc subdirectory changed implementation language from
C to C++, so, yes (as far as this bug is concerned).

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2021-11-30 10:38 ` amonakov at gcc dot gnu.org
@ 2021-11-30 11:48 ` egallager at gcc dot gnu.org
  2023-09-10 15:34 ` egallager at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-11-30 11:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |easyhack

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #7)
> As I understand, only the gcc subdirectory changed implementation language
> from C to C++, so, yes (as far as this bug is concerned).

ok, that makes things simpler; adding the "easyhack" keyword

(I might take a shot at this myself, but will stop short of self-assigning,
since there's other things I'm focusing on currently)

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

* [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations
       [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2021-11-30 11:48 ` egallager at gcc dot gnu.org
@ 2023-09-10 15:34 ` egallager at gcc dot gnu.org
  8 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2023-09-10 15:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91972

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|easyhack                    |

--- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> ---
so, I've tried enabling this flag while building, and one problem with it is
that GCC's genfoo machinery for its garbage collection system creates a bunch
of gt-*.h headers with a bunch of autogenerated gt_ggc_mx and gt_pch_nx
functions in them that all get warned about... this will require messing with
the generator utilities to get them to stop generating code that warns, so this
will be more difficult than I thought; removing the "easyhack" keyword...

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

end of thread, other threads:[~2023-09-10 15:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91972-4@http.gcc.gnu.org/bugzilla/>
2020-05-05  9:42 ` [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations amonakov at gcc dot gnu.org
2020-05-05 13:24 ` redi at gcc dot gnu.org
2020-05-05 13:34 ` rguenth at gcc dot gnu.org
2020-05-05 14:01 ` amonakov at gcc dot gnu.org
2020-06-08  1:55 ` egallager at gcc dot gnu.org
2021-11-30  7:18 ` egallager at gcc dot gnu.org
2021-11-30 10:38 ` amonakov at gcc dot gnu.org
2021-11-30 11:48 ` egallager at gcc dot gnu.org
2023-09-10 15:34 ` egallager at gcc dot gnu.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).