Bug 26036 - [4.0/4.1/4.2 Regression] Treating a class object as a function with member variables causes hang
Summary: [4.0/4.1/4.2 Regression] Treating a class object as a function with member va...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.2
: P2 normal
Target Milestone: 4.0.4
Assignee: Volker Reichelt
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-01-30 16:49 UTC by pcdoctor
Modified: 2006-04-19 17:46 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0 3.3.3
Known to fail: 4.0.3 4.1.0 4.2.0
Last reconfirmed: 2006-01-30 18:07:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pcdoctor 2006-01-30 16:49:34 UTC
The following code, while invalid, causes g++ >= 4.0.0 to hang while compiling.  Please note that "i" is also undeclared.  GCC 3.4.4 errors out as expected.


class TestClass {
public:
        int m_z;
};

class WrapperClass {
public:
        TestClass m_test;
};

int main()
{
   WrapperClass wrapper0(TestClass(i));
   return wrapper0().m_test.m_z++;
}
Comment 1 pcdoctor 2006-01-30 17:41:34 UTC
(In reply to comment #0)
>  Please note that "i" is also undeclared. 
Err, i is not a variable.... so ignore that statement.  I am assuming gcc is treating the "WrapperClass wrapper0(TestClass(i));" as a declaration instead of instantiation.  Still, the compiler should not hang.
Comment 2 Andrew Pinski 2006-01-30 18:07:47 UTC
I don't get a hang but I do get an ICE after some errors.


Confirmed.
Comment 3 Mark Mitchell 2006-01-31 02:44:49 UTC
This is a relatively low priority regression; we get valid errors before the crash.
Comment 4 Volker Reichelt 2006-02-02 09:54:59 UTC
Here's a simpler testcase with only one error:

=======================
struct A
{
    int i;
};

A foo(int);

void bar()
{
    foo().i;
}
=======================
Comment 5 Mark Mitchell 2006-02-24 00:26:50 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 6 Volker Reichelt 2006-04-19 09:34:55 UTC
Mark,
are you really working on this one or did you only accidentally assign the PR to
you? The following fixes the problem for me and allows to get rid of
error_mark_list as it is then unused:

===================================================================
--- gcc/gcc/cp/typeck.c	2006-04-18 17:32:06 +0200
+++ gcc/gcc/cp/typeck.c	2006-04-18 17:32:31 +0200
@@ -2788,7 +2788,7 @@ convert_arguments (tree typelist, tree v
 	    }
 	  else
 	    error ("too few arguments to function");
-	  return error_mark_list;
+	  return error_mark_node;
 	}
     }
 
===================================================================
Comment 7 Mark Mitchell 2006-04-19 16:57:08 UTC
Subject: Re:  [4.0/4.1/4.2 Regression] Treating a class object
 as a function with member variables causes hang

reichelt at gcc dot gnu dot org wrote:
> ------- Comment #6 from reichelt at gcc dot gnu dot org  2006-04-19 09:34 -------
> Mark,
> are you really working on this one or did you only accidentally assign the PR
> to
> you? 

Well, I planned to fix it before the next release, but I wasn't actually
doing anything on it.  You're always welcome to fix my bugs. :-)

> The following fixes the problem for me and allows to get rid of
> error_mark_list as it is then unused:
> 
> ===================================================================
> --- gcc/gcc/cp/typeck.c 2006-04-18 17:32:06 +0200
> +++ gcc/gcc/cp/typeck.c 2006-04-18 17:32:31 +0200
> @@ -2788,7 +2788,7 @@ convert_arguments (tree typelist, tree v
>             }
>           else
>             error ("too few arguments to function");
> -         return error_mark_list;
> +         return error_mark_node;
>         }
>      }

I can't argue with that. :-)  This patch, and the removal of
error_mark_list are fine.

Thanks,

Comment 8 Volker Reichelt 2006-04-19 17:37:04 UTC
Subject: Bug 26036

Author: reichelt
Date: Wed Apr 19 17:36:59 2006
New Revision: 113087

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113087
Log:
	PR c++/26036
	* typeck.c (convert_arguments): Return error_mark_node instead of
	error_mark_list.
	* cp-tree.h (error_mark_list): Remove declaration.
	* decl.c (error_mark_list): Remove definition.
	(cxx_init_decl_processing): Do not initialize error_mark_list.

	* g++.dg/expr/call3.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/expr/call3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Volker Reichelt 2006-04-19 17:40:36 UTC
Subject: Bug 26036

Author: reichelt
Date: Wed Apr 19 17:40:27 2006
New Revision: 113088

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113088
Log:
	PR c++/26036
	* typeck.c (convert_arguments): Return error_mark_node instead of
	error_mark_list.
	* cp-tree.h (error_mark_list): Remove declaration.
	* decl.c (error_mark_list): Remove definition.
	(cxx_init_decl_processing): Do not initialize error_mark_list.

	* g++.dg/expr/call3.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/expr/call3.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/cp-tree.h
    branches/gcc-4_1-branch/gcc/cp/decl.c
    branches/gcc-4_1-branch/gcc/cp/typeck.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 10 Volker Reichelt 2006-04-19 17:43:06 UTC
Subject: Bug 26036

Author: reichelt
Date: Wed Apr 19 17:43:01 2006
New Revision: 113089

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113089
Log:
	PR c++/26036
	* typeck.c (convert_arguments): Return error_mark_node instead of
	error_mark_list.
	* cp-tree.h (error_mark_list): Remove declaration.
	* decl.c (error_mark_list): Remove definition.
	(cxx_init_decl_processing): Do not initialize error_mark_list.

	* g++.dg/expr/call3.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/expr/call3.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/cp-tree.h
    branches/gcc-4_0-branch/gcc/cp/decl.c
    branches/gcc-4_0-branch/gcc/cp/typeck.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 11 Volker Reichelt 2006-04-19 17:46:31 UTC
Fixed on mainline, 4.1 branch, and 4.0 branch.
Comment 12 patchapp@dberlin.org 2006-04-19 17:50:14 UTC
Subject: Bug number PR c++/26036

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00711.html