public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols
@ 2020-06-19  9:55 hyena at hyena dot net.ee
  2020-06-19 12:08 ` [Bug c++/95763] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hyena at hyena dot net.ee @ 2020-06-19  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95763
           Summary: Feature request: compiler warning if line width
                    exceeds N symbols
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic, easyhack
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hyena at hyena dot net.ee
  Target Milestone: ---

Actually, this is a feature request, not a bug report.

It would be very useful if I could specify in a source file the maximum number
of symbols per line that the source file is allowed to contain. If some line
exceeds that limit, then the compiler should print the respective warning
mentioning the line number where the limit is exceeded.

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

* [Bug c++/95763] Feature request: compiler warning if line width exceeds N symbols
  2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
@ 2020-06-19 12:08 ` redi at gcc dot gnu.org
  2020-06-19 13:12 ` hyena at hyena dot net.ee
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-19 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems like a better fit for something like clang-tidy than being hardcoded
into the compiler.

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

* [Bug c++/95763] Feature request: compiler warning if line width exceeds N symbols
  2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
  2020-06-19 12:08 ` [Bug c++/95763] " redi at gcc dot gnu.org
@ 2020-06-19 13:12 ` hyena at hyena dot net.ee
  2020-06-19 14:42 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hyena at hyena dot net.ee @ 2020-06-19 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Erich Erstu <hyena at hyena dot net.ee> ---
(In reply to Jonathan Wakely from comment #1)
> This seems like a better fit for something like clang-tidy than being
> hardcoded into the compiler.

I can see the reasoning there, but different source/header files may have
different maximum line width limitations. For example, we may have a project
where most files are limited to 80 symbols per line but a subset of header
files is limited to 240 symbols per line (as an exception). So, this could not
be handled as a project-wide restriction but rather case-by-case. For example,
those header files may contain large multidimensional nested arrays/tables
(basically data) which requires an exception to be made.

For the above reasons, it would make sense to keep the line width limit as part
of the code file that is supposed to respect that limit. Clang-tidy would have
to get these limits from an external configuration file which bloats the
project. Since GCC already implements special comments such as "// fall
through" for switch statements, I could see this implemented similarly, as a
comment in the beginning of the code file.

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

* [Bug c++/95763] Feature request: compiler warning if line width exceeds N symbols
  2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
  2020-06-19 12:08 ` [Bug c++/95763] " redi at gcc dot gnu.org
  2020-06-19 13:12 ` hyena at hyena dot net.ee
@ 2020-06-19 14:42 ` joseph at codesourcery dot com
  2020-06-19 14:55 ` jakub at gcc dot gnu.org
  2021-04-17 21:36 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2020-06-19 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
FWIW, the Ada front end has some style checking support (I once broke 
bootstrap by applying spelling corrections there, where fixing the 
spelling in a comment made a line too long).  It wouldn't be ridiculous to 
have such checks available for C and C++, so far as formatting checks work 
reasonably in the presence of macros.

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

* [Bug c++/95763] Feature request: compiler warning if line width exceeds N symbols
  2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
                   ` (2 preceding siblings ...)
  2020-06-19 14:42 ` joseph at codesourcery dot com
@ 2020-06-19 14:55 ` jakub at gcc dot gnu.org
  2021-04-17 21:36 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-19 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The fortran FE also has diagnostics about source line lengths.
The question is e.g. if comments should be an exception or not.

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

* [Bug c++/95763] Feature request: compiler warning if line width exceeds N symbols
  2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
                   ` (3 preceding siblings ...)
  2020-06-19 14:55 ` jakub at gcc dot gnu.org
@ 2021-04-17 21:36 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-04-17 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement
   Last reconfirmed|                            |2021-04-17
     Ever confirmed|0                           |1

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I assume you are talking about stuff like:
int t, t1, t2, t43, t55, t6, t7888888, t99999, t999876, t323434, ttsdgsdg,
thfgd, tdfhghh, t354635463546;

?
If so confirmed. I have not looked into how to do this and if this is normally
not useful without a code style checker.

Having a code style checker part of GCC would be a good long term really.

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

end of thread, other threads:[~2021-04-17 21:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19  9:55 [Bug c++/95763] New: Feature request: compiler warning if line width exceeds N symbols hyena at hyena dot net.ee
2020-06-19 12:08 ` [Bug c++/95763] " redi at gcc dot gnu.org
2020-06-19 13:12 ` hyena at hyena dot net.ee
2020-06-19 14:42 ` joseph at codesourcery dot com
2020-06-19 14:55 ` jakub at gcc dot gnu.org
2021-04-17 21:36 ` pinskia 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).