[Bug c++/69323] New: Segmentation fault when instantiating class template with inner class which declares itself as a friend

2016-01-16 Thread bd at jollyrogerlabs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69323

Bug ID: 69323
   Summary: Segmentation fault when instantiating class template
with inner class which declares itself as a friend
   Product: gcc
   Version: 4.6.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bd at jollyrogerlabs dot com
  Target Milestone: ---

Created attachment 37379
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37379&action=edit
Preprocessed file, generated by adding "-save-temps" immediately after "g++" on
the command line.

Playing around with some template tricks (thus the filename) and produced a
segmentation fault.  Additionally, the error was generated from a program that
was very similar to one already working correctly, to which I attempted to have
an inner class of a class template (actually struct in both cases but whatever)
make a static member function private and then declare itself as its own
friend.  So in addition to the preprocessed source generated with -save-temps,
I will attach the original source file with instructions on how to switch the
error on and off.

Finally, I will report this on Ubuntu launchpad as well and reference this
upstream bug ID in case this turns out to be some issue in how they are
packaging for release.



GCC version:
$ g++ --version
g++ (Ubuntu/Linaro 4.6.4-1ubuntu1~12.04) 4.6.4



System type:
Ubuntu 12.04 LTS 64 bit
$ uname -a
Linux apocalypse-ranch-office 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul
15 04:02:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/debian_version 
wheezy/sid



Compiler command line plus output:
$ g++ -Wall -std=c++0x -g -O0 -o /tmp/stupid_template_tricks
/tmp/stupid_template_tricks.cpp 
/tmp/stupid_template_tricks.cpp: In instantiation of
‘Outer<42>::StupidValueTrick’:
/tmp/stupid_template_tricks.cpp:62:13:   instantiated from here
/tmp/stupid_template_tricks.cpp:13:3: internal compiler error: Segmentation
fault
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
Preprocessed source stored into /tmp/ccO1MHdE.out file, please attach this to
your bugreport.

[Bug c++/69323] Segmentation fault when instantiating class template with inner class which declares itself as a friend

2016-01-16 Thread bd at jollyrogerlabs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69323

--- Comment #1 from Brian Davis  ---
Created attachment 37380
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37380&action=edit
Original source file

Please note line 7 of this file:
#define SHOW_GCC_BUG 1

If this line is commented out, the program compiles and runs normally on my
machine; if it is left in, the compiler generates a segmentation fault as
indicated in the bug description.

There are two conditional groups in the code related to this macro which
control inclusion of exactly two line of code: a friend declaration, and the
declaration of a private section of a struct which is enclosed within a struct
template.

Perhaps of additional note is that the template parameter is non-type ("int" in
this case).

[Bug c++/69323] [4.9/5/6 Regression] Segmentation fault when instantiating class template with inner class which declares itself as a friend

2016-01-16 Thread bd at jollyrogerlabs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69323

--- Comment #3 from Brian Davis  ---
I just ran downstairs and used this to break g++ 4.9.2 running on Ubuntu 15.04
as well, using my original source file.  Here's the compiler version string,
and I'll attach the preprocessed file:

$ g++ --version
g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2

[Bug c++/69323] [4.9/5/6 Regression] Segmentation fault when instantiating class template with inner class which declares itself as a friend

2016-01-16 Thread bd at jollyrogerlabs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69323

--- Comment #4 from Brian Davis  ---
Created attachment 37381
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37381&action=edit
Preprocessed file generated by g++ 4.9.2 on the same source file

Here's the preprocessed file used on 4.9.2; the compiler error message was
similar or exactly the same.