public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54928] New: Infinite output with after ICE with macro
@ 2012-10-14 23:17 cas43 at cs dot stanford.edu
  2012-10-15  0:14 ` [Bug c++/54928] " manu at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: cas43 at cs dot stanford.edu @ 2012-10-14 23:17 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54928
           Summary: Infinite output with after ICE with macro
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cas43@cs.stanford.edu


Compiling this without options produces infinite output.

#define M(x) x
template<class T> class A {void F(){M(sizeof(double));}};
template class A<int>;


Beginning of output:

prog.cpp: In instantiation of ‘void A<T>::F() [with T = int]’:
prog.cpp:3:16:   required from here
prog.cpp:2:45: internal compiler error: in tsubst_copy, at cp/pt.c:12349
 template<class T> class A {void F(){M(sizeof(double));}};
                                             ^
prog.cpp:1:14: note: in definition of macro 'M'
 #define M(x) x
              ^
prog.cpp:2:45: internal compiler error: in internal_error, at diagnostic.c:1069
 template<class T> class A {void F(){M(sizeof(double));}};
                                             ^
prog.cpp:1:14: note: in definition of macro 'M'
 #define M(x) x
              ^
<the last bit repeats over and over.>


Output of g++ -v:
Using built-in specs.
COLLECT_GCC=/new-gcc/i-4.8/bin/g++
COLLECT_LTO_WRAPPER=/new-gcc/i-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../s-4.8/configure --prefix=/new-gcc/i-4.8
Thread model: posix
gcc version 4.8.0 20121014 (experimental) (GCC) 


I filed the ICE leading up to the infinite loop as a separate bug.


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
@ 2012-10-15  0:14 ` manu at gcc dot gnu.org
  2012-10-15  8:59 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-15  0:14 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-15 00:14:01 UTC ---
internal_error should not do macro unwinding or even try to print the caret.
The ideas in this old patch can be used to implement that:

http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01836.html


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
  2012-10-15  0:14 ` [Bug c++/54928] " manu at gcc dot gnu.org
@ 2012-10-15  8:59 ` paolo.carlini at oracle dot com
  2012-10-15  9:17 ` manu at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-15  8:59 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-15 08:58:45 UTC ---
Thanks Manuel. Honestly, however, it's the first time in my life that I see
this problem, I suspect isn't *that* easy to trigger (I mean, when the core ICE
issue is fixed, has to do with recent work done by Jakub, should be easy to
fix). Is the problem related to the work Dodji did on macros? Should we involve
him?


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
  2012-10-15  0:14 ` [Bug c++/54928] " manu at gcc dot gnu.org
  2012-10-15  8:59 ` paolo.carlini at oracle dot com
@ 2012-10-15  9:17 ` manu at gcc dot gnu.org
  2012-10-15  9:25 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-15  9:17 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-15 09:17:28 UTC ---
If an internal_error is triggered during macro unwinding, then it will try to
macro unwind it, triggering the bug again, and so on. See:

prog.cpp:2:45: internal compiler error: in internal_error, at diagnostic.c:1069

I guess the same could happen with the caret code, if some bug may produce an
ICE there. I think the best would be to disable both caret diagnostics and
macro unwinding for ICEs.

I suspect also that it is not easy to trigger, but it is indeed a bug (even if
the issue triggering the first ICE is fixed).


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (2 preceding siblings ...)
  2012-10-15  9:17 ` manu at gcc dot gnu.org
@ 2012-10-15  9:25 ` paolo.carlini at oracle dot com
  2012-10-15  9:27 ` manu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-15  9:25 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-15 09:25:08 UTC ---
I see. Any chance you can prepare an actual patch?


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (3 preceding siblings ...)
  2012-10-15  9:25 ` paolo.carlini at oracle dot com
@ 2012-10-15  9:27 ` manu at gcc dot gnu.org
  2012-10-15  9:31 ` manu at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-15  9:27 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, error-recovery
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-15
     Ever Confirmed|0                           |1

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-15 09:27:25 UTC ---
~/test3/192379/build/gcc/cc1plus pr54928.cc -ftrack-macro-expansion=0

does not trigger the infinite loop. So the macro code is causing an additional
ICE somewhere.


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (4 preceding siblings ...)
  2012-10-15  9:27 ` manu at gcc dot gnu.org
@ 2012-10-15  9:31 ` manu at gcc dot gnu.org
  2012-10-16 18:00 ` manu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-15  9:31 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-15 09:31:06 UTC ---
(In reply to comment #4)
> I see. Any chance you can prepare an actual patch?

I want to revisit that old patch at some moment, but I don't think I will make
it before stage1 closes, sorry.

Independently of disabling macro unwinding and caret for ICE reporting, the
macro code is causing an additional ICE somewhere, it would be nice to know
where and if it requires fixing. Perhaps Dodji has some ideas what to look for.


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (5 preceding siblings ...)
  2012-10-15  9:31 ` manu at gcc dot gnu.org
@ 2012-10-16 18:00 ` manu at gcc dot gnu.org
  2012-10-16 18:06 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-16 18:00 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-16 17:59:57 UTC ---
This is the problem:

Index: tree-diagnostic.c
===================================================================
--- tree-diagnostic.c   (revision 192379)
+++ tree-diagnostic.c   (working copy)
@@ -239,10 +239,13 @@ maybe_unwind_expanded_macro_loc (diagnos
            pp_destroy_prefix (context->printer);
            diagnostic_show_locus (context, diagnostic);
            /* At this step, as we've printed the context of the macro
               definition, we don't want to print the context of its
               expansion, otherwise, it'd be redundant.  */
+            diagnostic->kind = saved_kind;
+            diagnostic->location = saved_location;
+            pp_set_prefix (context->printer, saved_prefix);
            continue;
          }

        diagnostic->location = resolved_exp_loc;
        pp_set_prefix (context->printer,

But I think the code can be a lot simpler with a slightly more complex patch.


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (6 preceding siblings ...)
  2012-10-16 18:00 ` manu at gcc dot gnu.org
@ 2012-10-16 18:06 ` manu at gcc dot gnu.org
  2012-10-16 22:26 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-16 18:06 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-16 18:05:52 UTC ---
Created attachment 28457
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28457
better fix

The code is re-using the diagnostic passed as an argument to produce new
diagnostics, and by saving/reloading values on it. But we actually only need to
modify things once, and if we use a new diagnostic struct, we don't need to
touch the original.

Of course, we should still not print the caret and macro expansion in
internal_error, but that is a bit more complicated.


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (7 preceding siblings ...)
  2012-10-16 18:06 ` manu at gcc dot gnu.org
@ 2012-10-16 22:26 ` paolo.carlini at oracle dot com
  2012-10-24 22:02 ` manu at gcc dot gnu.org
  2012-10-24 22:25 ` manu at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-16 22:26 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-16 22:26:40 UTC ---
Well, you know that already, but I have to remind you that this is not the best
place to send patches. When you consider your fix mature enough (IMHO it is
already! ;) please send it to the mailing list!! Thanks for all your help!


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (8 preceding siblings ...)
  2012-10-16 22:26 ` paolo.carlini at oracle dot com
@ 2012-10-24 22:02 ` manu at gcc dot gnu.org
  2012-10-24 22:25 ` manu at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-24 22:02 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-24 22:01:54 UTC ---
Author: manu
Date: Wed Oct 24 22:01:50 2012
New Revision: 192786

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192786
Log:
2012-10-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    PR c++/54928
    * tree-diagnostic.c (maybe_unwind_expanded_macro_loc):
    Use diagnostic_append_note.
    * diagnostic.c (diagnostic_build_prefix): Make diagnostic const.
    (default_diagnostic_finalizer): Do not destroy prefix here.
    (diagnostic_report_diagnostic): Destroy it here.
    (diagnostic_append_note): New.
    * diagnostic.h (diagnostic_append_note): Declare.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ada/s-fore.ads
    trunk/gcc/diagnostic.c
    trunk/gcc/diagnostic.h
    trunk/gcc/tree-diagnostic.c


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

* [Bug c++/54928] Infinite output with after ICE with macro
  2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
                   ` (9 preceding siblings ...)
  2012-10-24 22:02 ` manu at gcc dot gnu.org
@ 2012-10-24 22:25 ` manu at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-24 22:25 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #11 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-24 22:24:43 UTC ---
This is fixed in GCC 4.8, but something weird happened in the commit, because I
didn't touch ada/s-fore.ads and there are no changes to that file when I do
'svn diff'. Very strange.


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

end of thread, other threads:[~2012-10-24 22:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-14 23:17 [Bug c++/54928] New: Infinite output with after ICE with macro cas43 at cs dot stanford.edu
2012-10-15  0:14 ` [Bug c++/54928] " manu at gcc dot gnu.org
2012-10-15  8:59 ` paolo.carlini at oracle dot com
2012-10-15  9:17 ` manu at gcc dot gnu.org
2012-10-15  9:25 ` paolo.carlini at oracle dot com
2012-10-15  9:27 ` manu at gcc dot gnu.org
2012-10-15  9:31 ` manu at gcc dot gnu.org
2012-10-16 18:00 ` manu at gcc dot gnu.org
2012-10-16 18:06 ` manu at gcc dot gnu.org
2012-10-16 22:26 ` paolo.carlini at oracle dot com
2012-10-24 22:02 ` manu at gcc dot gnu.org
2012-10-24 22:25 ` manu 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).