Bug 23589 - internal compiler error: in rest_of_handle_final, at toplev.c:2067
internal compiler error: in rest_of_handle_final, at toplev.c:2067
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
3.4.4
: P2 normal
: 4.1.0
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
: 23590 24048 (view as bug list)
Depends on: 21081 21275 21766
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-27 03:31 UTC by Greg Couch
Modified: 2005-10-12 21:06 UTC (History)
2 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2005-08-27 12:13:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Couch 2005-08-27 03:31:36 UTC
This code works with the previous cygwin compiler that was based on gcc 3.3.3.
Thank you for looking at this.

"gcc -v" gives:

Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug : (reconfigured)
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)

The output when compiling with "gcc -c t.cpp":

t.cpp: In constructor `Point::Point(pointIterator, pointIterator) [with
pointIterator = __gnu_cxx::__normal_iterator<Point*, std::vector<Point,
std::allocator<Point> > >]':
t.cpp:22:   instantiated from `Point::Point(pointIterator, pointIterator) [with
pointIterator = __gnu_cxx::__normal_iterator<Point*, std::vector<Point,
std::allocator<Point> > >]'
t.cpp:34:   instantiated from here
t.cpp:22: internal compiler error: in rest_of_handle_final, at toplev.c:2067
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Here is the source of the program (37 lines):

#include <iostream>
#include <vector>

// This is from an include file in a library.  If OTF_IMEX is instead
// defined to be __declspec(dllexport), then it compiles, but that
// should only be done in the compliation of the library, not where it
// is included.
#  define OTF_IMEX __declspec(dllimport)

class OTF_IMEX Point {
        float data_[3];
        friend inline std::ostream& operator<<(std::ostream&, const Point&);
public:
        Point();
        Point(float x, float y, float z);
        template <class pointIterator>
                Point(pointIterator ptStart, pointIterator ptStop);
};

template <class pointIterator>
Point::Point(pointIterator ptStart, pointIterator ptStop)
{
        // construct a point that is the average of the given points
}

// back to your normal program that included the above

int
main()
{
        std::vector<Point> points;
        points.push_back(Point(0, 0, 0));
        points.push_back(Point(1, 1, 1));
        Point pt(points.begin(), points.end());
        std::cout << "average point: " << pt << '\n';
        return 0;
}
Comment 1 Andrew Pinski 2005-08-27 03:37:44 UTC
*** Bug 23590 has been marked as a duplicate of this bug. ***
Comment 2 Danny Smith 2005-08-27 04:44:31 UTC
Thisis a dllimport bug. In this case the template member
template <class pointIterator>
Point::Point(pointIterator ptStart, pointIterator ptStop)
is being marked as dllimport.  Later it is instantiated and the definition 
conflicts with dllimport semantics 

The same bug is on trunk and is fixed by the patch at 
http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01543.html

by moving the C++ specific dllimport stuff into a lang-specific target file so 
that we can actually test for template instantiations.

Danny
Comment 3 Greg Couch 2005-08-27 21:51:07 UTC
Subject: Re:  internal compiler error: in rest_of_handle_final,
 at toplev.c:2067

Much appreciated.  Thank you.

On Fri, 27 Aug 2005, dannysmith at users dot sourceforge dot net wrote:

> Date: 27 Aug 2005 04:44:32 -0000
> From: dannysmith at users dot sourceforge dot net <gcc-bugzilla@gcc.gnu.org>
> To: gregc@cgl.ucsf.edu
> Subject: [Bug target/23589] internal compiler error: in rest_of_handle_final,
>     at toplev.c:2067
> 
>
> ------- Additional Comments From dannysmith at users dot sourceforge dot net  2005-08-27 04:44 -------
> Thisis a dllimport bug. In this case the template member
> template <class pointIterator>
> Point::Point(pointIterator ptStart, pointIterator ptStop)
> is being marked as dllimport.  Later it is instantiated and the definition
> conflicts with dllimport semantics
>
> The same bug is on trunk and is fixed by the patch at
> http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01543.html
>
> by moving the C++ specific dllimport stuff into a lang-specific target file so
> that we can actually test for template instantiations.
>
> Danny
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23589
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
Comment 4 Andrew Pinski 2005-09-24 15:47:01 UTC
*** Bug 24048 has been marked as a duplicate of this bug. ***
Comment 5 CVS Commits 2005-10-12 20:54:57 UTC
Subject: Bug 23589

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dannysmith@gcc.gnu.org	2005-10-12 20:54:50

Modified files:
	gcc            : ChangeLog config.gcc tree.c tree.h varasm.c 
	                 target.h target-def.h 
	gcc/doc        : tm.texi 
	gcc/config/i386: i386-protos.h i386.c winnt.c cygming.h 
	                 t-cygming 
	gcc/cp         : ChangeLog class.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg: dll-2.c dll-3.c dll-4.c 
	gcc/testsuite/g++.dg/ext: dllimport1.C dllimport2.C dllimport3.C 
	                          dllimport7.C dllimport8.C dllimport9.C 
Added files:
	gcc/config/i386: winnt-stubs.c winnt-cxx.c 

Log message:
	PR middle-end/21275
	PR middle-end/21766
	* target.h (struct gcc_target): Add valid_dllimport_attribute_p
	target hook.
	(struct cxx): Add adjust_class_at_definition target hook.
	* target-def.h: (TARGET_VALID_DLLIMPORT_ATTRIBUTE_P): New define,
	defaulting to hook_bool_tree_true. Add to TARGET_INITIALIZER
	(TARGET_CXX_ADJUST_CLASS_AT_DEFINITION): New define, defaulting to
	hook_void_tree. Add to TARGET_CXX.
	* tree.h (struct decl_with_vis): Rename non_addr_const_p field to
	dllimport_flag.
	(DECL_NON_ADDR_CONSTANT_P): Replace with DECL_DLLIMPORT_P macro.
	* tree.c (merge_dllimport_decl_attributes): Check DECL_DLLIMPORT_P
	instead of attribute. Check for dllexport override.  Warn if
	inconsistent dll linkage. Don't lose old dllimport if decl has
	had address referenced.   Tweak lookup of dllimport atribute.
	(handle_dll_attribute): Check targetm.valid_dllimport_attribute_p
	for target specific rules.  Don't add dllimport attribute if
	DECL_DECLARED_INLINE_P.  Set DECL_DLLIMPORT_P when adding
	dllimport attribute.
	(staticp): Replace DECL_NON_ADDR_CONSTANT_P with DECL_DLLIMPORT_P.
	* varasm.c (initializer_constant_valid_p): Replace
	DECL_NON_ADDR_CONSTANT_P with DECL_DLLIMPORT_P
	
	PR target/21801
	PR target/23589
	* config.gcc (i[34567]86-*-cygwin*): Add winnt-cxx.o to
	'cxx_target_objs', winnt-stubs,o to 'extra_objs'.
	(i[34567]86-*-mingw32*): Likewise.
	
	* doc/tm.texi (TARGET_CXX_ADJUST_CLASS_AT_DEFINITION): Document.
	(TARGET_VALID_DLLIMPORT_ATTRIBUTE_P): Document.
	
	* config/i386/winnt.c (i386_pe_dllimport_p): Factor out
	C++-specific code. Change return value to bool.
	(i386_pe_dllimport_p): Likewise.
	(associated_type): Simplify and make language-independent
	(i386_pe_encode_section_info): Replace override of ambiguous
	dllimport symbol refs with a gcc_assert.
	(i386_pe_valid_dllimport_attribute_p): Define.
	* config/i386/winnt-cxx.c: New file. Define C++ versions of
	i386_pe_type_dllimport_p, i386_pe_type_dllexport_p,
	i386_pe_adjust_class_at_definition.
	* config/i386/winnt-stubs.c: New file. Define stub versions of
	lang-specific functions.
	* config/i386/i386-protos.h: Declare winnt-[cxx|stubs].c functions
	i386_pe_type_dllimport_p, i386_pe_type_dllexport_p,
	i386_pe_adjust_class_at_definition.
	(i386_pe_valid_dllimport_attribute_p): Declare.
	* config/i386/cygming.h (TARGET_VALID_DLLIMPORT_ATTRIBUTE_P): Define.
	(TARGET_CXX_ADJUST_CLASS_AT_DEFINITION): Define.
	* config/i386/t-cygming: Add rules for winnt-cxx.o, winnt-stubs.o.
	
	PR target/19704
	* config/i386/i386.c (ix86_function_ok_for_sibcall): Replace test for
	dllimport attribute with test of DECL_DLLIMPORT_P.
	
	cp
	PR target/21801
	PR target/23589
	* class.c (finish_struct_1): Call
	targetm.cxx.adjust_class_at_definition.
	
	testsuite
	* gcc.dg/dll-2.c: Add tests for warnings.
	* gcc.dg/dll-3.c: Likewise.
	* gcc.dg/dll-4.c: Likewise.
	
	* g++.dg/ext/dllimport1.C: Adjust tests for warnings.
	* g++.dg/ext/dllimport2.C: Likewise.
	* g++.dg/ext/dllimport3.C: Likewise.
	* g++.dg/ext/dllimport7.C: Likewise.
	* g++.dg/ext/dllimport8.C: Likewise.
	* g++.dg/ext/dllimport9.C: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10149&r2=2.10150
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config.gcc.diff?cvsroot=gcc&r1=1.568&r2=1.569
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&r1=1.508&r2=1.509
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.757&r2=1.758
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.532&r2=1.533
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/target.h.diff?cvsroot=gcc&r1=1.144&r2=1.145
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/target-def.h.diff?cvsroot=gcc&r1=1.133&r2=1.134
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/tm.texi.diff?cvsroot=gcc&r1=1.446&r2=1.447
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/winnt-stubs.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/winnt-cxx.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386-protos.h.diff?cvsroot=gcc&r1=1.147&r2=1.148
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.862&r2=1.863
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/winnt.c.diff?cvsroot=gcc&r1=1.84&r2=1.85
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/cygming.h.diff?cvsroot=gcc&r1=1.32&r2=1.33
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/t-cygming.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4927&r2=1.4928
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.734&r2=1.735
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6183&r2=1.6184
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/dll-2.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/dll-3.c.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/dll-4.c.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport1.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport2.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport3.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport7.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport8.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport9.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 6 Danny Smith 2005-10-12 20:59:52 UTC
Fixed on trunk.
http://gcc.gnu.org/ml/gcc-cvs/2005-10/msg00474.html
Danny
Comment 7 Andrew Pinski 2005-10-12 21:06:34 UTC
Fixed.
Comment 8 CVS Commits 2005-10-18 22:06:02 UTC
Subject: Bug 23589

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dannysmith@gcc.gnu.org	2005-10-18 22:05:57

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: dllimport11.C 

Log message:
	PR target/23589
	* g++.dg/ext/dllimport11.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6211&r2=1.6212
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/dllimport11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1