------- Comment #4 from matz at gcc dot gnu dot org  2009-01-28 12:22 -------
I'm fairly sure it's the same underlying problem.  The emitted file numbers
(in the .s file for debug info) are in garbage collected memory.  Hence
the directives emitted when the PCH is not yet loaded and those emitted after
it's loaded might use the same file number.  In this case you use -g3, meaning
to emit directives for defined macros.  These are emitted (obviously) as soon
as the include directive is seen.  This will allocate numbers 1 and 2 for
main.cpp and main.h.  Then the PCH file is loaded, overwriting the internally
(in dwarf2out.c:struct dwarf_file_data) stored file numbers, so we start
counting from 2 again (we overwrite only data from after the main file),
which is given to main.cpp again.

Hence the assembler gives the error message.

Later compilers simply segfault already earlier in the process, because
location info is also overwritten but still referenced, as detailed
in the https://bugzilla.novell.com/show_bug.cgi?id=444153 .

Also, as detailed there, it seems to be a fundamental design choice that the
PCH has to be included from the main file, as the PCH machinery uses the
garbage collection engine to actually retrieve the memory state like it
was when precompiling the file.  This obviously can only work if no stale
references exist to then overwritten information and this in turn can only
be ensured when there isn't "too much" information before loading the PCH file
at all.

No idea how easy this would be to fix, from a cursory look at the whole
machinery it looks quite difficult (at least if one wants to really fix
this, and not just work-around the cases that people happen to hit)


-- 


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

Reply via email to