Bug 9963 - [CygWin] g++ -gcoff report "C_EFCN symbol out of scope"
Summary: [CygWin] g++ -gcoff report "C_EFCN symbol out of scope"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2003-03-05 08:36 UTC by smartnoho
Modified: 2005-04-05 04:15 UTC (History)
3 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2003-07-11 20:58:52


Attachments
testgcc.cpp (101 bytes, application/octet-stream)
2003-05-21 15:17 UTC, smartnoho
Details
This plain c source causes the same error message as c++ source. (73 bytes, text/plain)
2003-12-14 16:06 UTC, Benjamin Kalytta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description smartnoho 2003-03-05 08:36:01 UTC
The following code compile in gcc:
class Foo
{
public:
	Foo()
	{
	}
	~Foo()
	{
	}
};

int main(int argc, char * argv)
{
	Foo foo;
	return 0;
}

g++ testgcc.cpp -gcoff
/cygdrive/f/TEMP/ccdnNbaT.s: Assembler messages:
/cygdrive/f/TEMP/ccdnNbaT.s:1755: Fatal error: C_EFCN symbol out of scope

Release:
3.2 20020927 (prerelease) released with cygwin

Environment:
PIII 550
Windows 2000
Comment 1 Dara Hazeghi 2003-05-26 19:05:32 UTC
Hello,

gcc 3.2 is rather old now. Would it be possible for you to check whether this problem is still 
present in gcc 3.3? Thanks,

Dara
Comment 2 Andrew Pinski 2003-05-26 19:10:18 UTC
See Dara's question.
Comment 3 Dara Hazeghi 2003-06-21 00:08:40 UTC
Hello. Just a reminder that this bug is in waiting. Have you had a chance to test gcc 3.3 yet for this 
problem? Thanks.
Comment 4 Dara Hazeghi 2003-07-11 20:58:52 UTC
Confirmed with gcc 3.3 branch and mainline (20030711). No further feedback
necessary.
Comment 5 Benjamin Kalytta 2003-12-14 15:54:44 UTC
Have the same bug here in gcc 3.3.x.

/* forward declaration */
int Test();

void* Fnc = Test;

int Test() {
}

Problem may be caused by forward declaration of function test.
Comment 6 Benjamin Kalytta 2003-12-14 16:06:09 UTC
Created attachment 5333 [details]
This plain c source causes the same error message as c++ source.

Only if variable Fnc is declared before function decleration the error is
caused, otherwise not.
Comment 7 Benjamin Kalytta 2003-12-15 14:07:31 UTC
The problem is, that gcc produces 2 .def .endef blocks for the same function.
(Is this allowed? At least ld don't want this!)

Function i386_pe_file_end() in /gcc/config/i386/winnt.c shouldn't call 
i386_pe_declare_function_type() if -gcoff (SDB_DEBUG) is set.
Commenting it out would solve this problem for the moment.
Comment 8 smartnoho 2003-12-16 09:24:44 UTC
GCC 3.3.1 (cygming special) is ok.
Comment 9 Pavel Palát 2004-02-17 17:21:38 UTC
The problem still exists with latest gcc 3.3.2 compiled as a cross compiler for
i386-mingw32 from i686-pc-linux target.
Comment 10 Ian Lance Taylor 2005-03-27 17:14:04 UTC
This bug appears to still exists in mainline.  When I compile the test case
without optimization, I get both these lines
	.def	_Test;	.val	_Test;	.scl	2;	.type	044;	.endef
	.def	_Test;	.scl	3;	.type	32;	.endef
The second line is incorrect.  When it happens to be emitted first, it doesn't
matter.  When it is emitted second, it does matter.

The note closing this PR says "GCC 3.3.1 (cygming special) is ok."  Does the
"cygming special" refer to a patched compiler?
Comment 11 Ian Lance Taylor 2005-03-27 18:54:05 UTC
Patch here:
    http://gcc.gnu.org/ml/gcc-patches/2005-03/msg02460.html
Comment 12 GCC Commits 2005-04-05 04:09:07 UTC
Subject: Bug 9963

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ian@gcc.gnu.org	2005-04-05 04:08:57

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: cygming.h i386-protos.h winnt.c 

Log message:
	PR debug/9963
	* config/i386/cygming.h (ASM_OUTPUT_EXTERNAL): Pass DECL to
	i386_pe_record_external_function.
	(i386_pe_record_external_function): Update declaration.
	* config/i386/winnt.c (struct extern_list): Add decl field.
	(i386_pe_record_external_function): Add decl parameter.
	(i386_pe_file_end): Check TREE_ASM_WRITTEN on decl, not
	identifier.
	* config/i386/i386-protos.h (i386_pe_record_external_function):
	Update declaration.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8135&r2=2.8136
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/cygming.h.diff?cvsroot=gcc&r1=1.25&r2=1.26
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386-protos.h.diff?cvsroot=gcc&r1=1.133&r2=1.134
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/winnt.c.diff?cvsroot=gcc&r1=1.77&r2=1.78

Comment 13 Ian Lance Taylor 2005-04-05 04:15:03 UTC
Fixed on mainline.