public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller
@ 2011-01-24  5:32 navin.kumar at gmail dot com
  2011-01-24  8:17 ` [Bug c++/47429] " navin.kumar at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: navin.kumar at gmail dot com @ 2011-01-24  5:32 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: -Wfatal-errors hiding line number of offending caller
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: navin.kumar@gmail.com


When compiling with -Wfatal-errors, the line number of the offending caller is
not visible.

Code:
class Blah {
  int test;
};

struct Evil : public Blah {
  int test() { return Blah::test; }
};


When compiling with g++ -c -Wall -Werror, the output is:
test.cc: In member function 'int Evil::test()':
test.cc:3:6: error: 'int Blah::test' is private
test.cc:8:28: error: within this context

When compiling with g++ -c -Wall -Werror -Wfatal-errors, the output is:
test.cc: In member function 'int Evil::test()':
test.cc:3:6: error: 'int Blah::test' is private

There is no mention of line 8 when "-Wfatal-errors" is used.


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
@ 2011-01-24  8:17 ` navin.kumar at gmail dot com
  2011-01-24 13:53 ` manu at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: navin.kumar at gmail dot com @ 2011-01-24  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Navin Kumar <navin.kumar at gmail dot com> 2011-01-24 04:50:18 UTC ---
(re-pasted error output):

When compiling with g++ -c -Wall -Werror, the output is:
test.cc: In member function ‘int Evil::test()’:
test.cc:2:6: error: ‘int Blah::test’ is private
test.cc:6:28: error: within this context

When compiling with g++ -c -Wall -Werror -Wfatal-errors, the output is:
test.cc: In member function ‘int Evil::test()’:
test.cc:2:6: error: ‘int Blah::test’ is private

There is no mention of line 6 when "-Wfatal-errors" is used.


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
  2011-01-24  8:17 ` [Bug c++/47429] " navin.kumar at gmail dot com
@ 2011-01-24 13:53 ` manu at gcc dot gnu.org
  2011-01-24 18:03 ` navin.kumar at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2011-01-24 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.01.24 13:26:01
                 CC|                            |manu at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-01-24 13:26:01 UTC ---
This is an old bug but I cannot find it in bugzilla. 

There are several issues:

* GCC doesn't have the concept of multi-line diagnostic, each line is
independent. That is, we cannot do error("this is one line.\nThis is another").
This is not difficult to implement but it is long and tedious.

* GCC cannot build a single diagnostic that expands several lines from
individual calls. That is, we cannot do 

Diagnostic diag;
diag.error("‘int Blah::test’ is private");
diag.note("within this context")
diag.report();

This is much harder (and ugly) to solve in C.

I am not sure about the status of Clang/LLVM with respect to this. Last time I
looked their diagnostic machinery was too strongly based on GCC's so they
suffered the same problem, but there have been loads of changes since then, so
perhaps they fixed it already.


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
  2011-01-24  8:17 ` [Bug c++/47429] " navin.kumar at gmail dot com
  2011-01-24 13:53 ` manu at gcc dot gnu.org
@ 2011-01-24 18:03 ` navin.kumar at gmail dot com
  2011-01-24 18:06 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: navin.kumar at gmail dot com @ 2011-01-24 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Navin Kumar <navin.kumar at gmail dot com> 2011-01-24 17:42:03 UTC ---
Wouldn't the simple fix be to make it a note() that 'int Blah::test' is private
and the error() be the caller's attempt to use it?


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
                   ` (2 preceding siblings ...)
  2011-01-24 18:03 ` navin.kumar at gmail dot com
@ 2011-01-24 18:06 ` manu at gcc dot gnu.org
  2011-01-24 18:34 ` navin.kumar at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2011-01-24 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-01-24 17:55:29 UTC ---
It is common in the C/C++ front-ends that error() is followed by one or more
notes() providing context, suggestions or more information. (That is, "error:
within this context" should be a note).

We could follow your proposal but I think it will change the output quite a bit
and make it more difficult to understand. There are other even more complex
cases, like printing template candidates, where there are multiple lines of
notes (which currently are multiple calls to inform()).


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
                   ` (3 preceding siblings ...)
  2011-01-24 18:06 ` manu at gcc dot gnu.org
@ 2011-01-24 18:34 ` navin.kumar at gmail dot com
  2011-01-24 18:35 ` froydnj at codesourcery dot com
  2011-01-24 23:17 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: navin.kumar at gmail dot com @ 2011-01-24 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Navin Kumar <navin.kumar at gmail dot com> 2011-01-24 18:07:45 UTC ---
Hmm.  I only need -Wfatal-errors because otherwise a small typo can cause
heavily templated code to go berserk and output 10,000 lines of errors. 
Perhaps a compromise is to have the ability to specify how many errors are
tolerated?  Instead of -Wfatal-errors that bombs on the first error, perhaps
-Wfatal-errors=5 that limits the output to 5 errors before failing?


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
                   ` (4 preceding siblings ...)
  2011-01-24 18:34 ` navin.kumar at gmail dot com
@ 2011-01-24 18:35 ` froydnj at codesourcery dot com
  2011-01-24 23:17 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: froydnj at codesourcery dot com @ 2011-01-24 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from froydnj at codesourcery dot com <froydnj at codesourcery dot com> 2011-01-24 18:09:12 UTC ---
On Mon, Jan 24, 2011 at 06:07:50PM +0000, navin.kumar at gmail dot com wrote:
> Instead of -Wfatal-errors that bombs on the first error, perhaps
> -Wfatal-errors=5 that limits the output to 5 errors before failing?

See -fmax-errors, new in 4.6.


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

* [Bug c++/47429] -Wfatal-errors hiding line number of offending caller
  2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
                   ` (5 preceding siblings ...)
  2011-01-24 18:35 ` froydnj at codesourcery dot com
@ 2011-01-24 23:17 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-01-24 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-01-24 23:02:44 UTC ---
This is working as designed.  -Wfatal-errors was really only designed to reduce
testcases and nothing else.

*** This bug has been marked as a duplicate of bug 37773 ***


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

end of thread, other threads:[~2011-01-24 23:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24  5:32 [Bug c++/47429] New: -Wfatal-errors hiding line number of offending caller navin.kumar at gmail dot com
2011-01-24  8:17 ` [Bug c++/47429] " navin.kumar at gmail dot com
2011-01-24 13:53 ` manu at gcc dot gnu.org
2011-01-24 18:03 ` navin.kumar at gmail dot com
2011-01-24 18:06 ` manu at gcc dot gnu.org
2011-01-24 18:34 ` navin.kumar at gmail dot com
2011-01-24 18:35 ` froydnj at codesourcery dot com
2011-01-24 23:17 ` 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).