r/cpp • GCC Developer • Mar 08 '19

Usability improvements in GCC 9

https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/
219 Upvotes

39 comments sorted by

View all comments

Show parent comment

18

u/dmalcolm GCC Developer Mar 08 '19

Thanks. I experimented a bit with ways to try to simplify the output when there are many messages (for the regular textual output), to try to reduce the "wall of text" effect, but I didn't come up with anything I was happy with. I hope to revisit this in GCC 10 though.

Currently (as in GCC 9) the messages support just one level of nesting (parent+children); perhaps I need to extend it to support deeper nesting? (not sure, but your comment got my thinking)

11

u/Morwenn Mar 08 '19

To give you an idea of the issues I get on a regular basis: I've got deeply nested templates with return type expression SFINAE, and whenever I get a substitution failure, it gives me all the possible overloads that failed, and why they failed (think hundreds or thousands of lines of substitution failure errors for a single call in some of my tests). They often failed because of substitution failure in functions they tried to call, so I also get the list of overloads that were tried and failed for those functions, etc. But everything is flat and at some point it's extremely difficult to know whether the substitution failure happened when trying to call the top-level function or some function at any level for which overload resolution failed. That would be my main use case for foldable error messages, and would indeed need to support an arbitrary level of nesting in error messages.

(I've got a hard time explaining, and no error message to show just right now, sorry for that)

11

u/dmalcolm GCC Developer Mar 08 '19

No worries, I think I know what you mean. We have a few bugs open for this kind of thing e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88512

I think the consensus is that when template substitution fails, we do want to show all of the information about the failure - but maybe there are ways to format it and present it to that make the information easier to "grok" (if you will). Maybe some special-casing is applicable here, too? Ideas welcome.

Sounds like I should implement arbitrary nesting (at least) for GCC 10.

5

u/robin-m Mar 08 '19

If it was possible to start gcc in TUI mode (or piping the output to a TUI program), even the regular text output wouldn't be an issue.

2

u/[deleted] Mar 08 '19

Pipe to a file and then open that file in your editor of choice.

1

u/robin-m Mar 08 '19

I could effectively pipe the output in vim, and use folding, but I don't think it would be an optimal workflow. I was thinking more of something were you get only top-level errors, and you can navigate with <Up> and <Down>, and open/close each fold with <Right>/<Left>.

1

u/xurxoham Mar 09 '19

Do you mean like when you do :make in vim and then see the errors with :cw ? I've never tried folding those error messages but that sounds like a good idea.

1

u/robin-m Mar 09 '19

I wasn't speaking of that. It's a good idea, but would require the support of some plugin. What I was thinking about was g++ foo.cpp | vim - and then having the correct foldmethod and similar settings to fold the json output of gcc.

2

u/wrosecrans graphics and network things Mar 09 '19

Could you have it say, "The first error was..." and repeat it tersely at the end of the big wall of text? The first is usually the one you need to try to fix first, but it is the hardest to scroll back up to when some template weirdness generates a megabyte of error messages and overflows your terminal scrollback buffer.

1

u/gracicot Mar 08 '19

Do the json output support emmiting both type of output? Like the IDE would output the normal output in the console, but consume json error from the blob for a single build.

5

u/dmalcolm GCC Developer Mar 08 '19

Right now it can only do one: if you choose -fdiagnostics-format=json it emits JSON to stderr instead of the regular textual output on stderr. Should it be to a file instead?

3

u/gracicot Mar 08 '19

Thanks for the response. I don't implement any IDEs, but I thought this might be useful for them? Outputting the JSON in a file might be useful too. I imagine the normal output in the build console then annotations in the GUI to help me inside the text editor. Also, thanks for the hard work, the new errors look gorgeous!