c++/3779: Accepts illegal C++ code: redefinition of default argument

Petter Reinholdtsen pere@mail.opera.no
Mon Jul 23 11:56:00 GMT 2001


>Number:         3779
>Category:       c++
>Synopsis:       Accepts illegal C++ code: redefinition of default argument
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 23 11:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Petter Reinholdtsen
>Release:        3.1 20010615 (experimental)
>Organization:
Hungry Programmers
>Environment:
System: Linux zoot 2.2.18 #3 SMP Thu Jan 18 16:29:19 CET 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/store/opt/gcc-cvs --program-prefix=pre3-
>Description:
	The CVS version of GCC accepts redefinition of default
	arguments.  This is illegal C++ and generates an error on
	SGI Irix C++ and Compaq C++.  It should be rejected on gcc as
	well.
>How-To-Repeat:
	Compile the following code.  It should generate an error, but
	gcc accept.

		class T {
		public:
		  T(int i = 0);
		private:
		  int m_i;
		};

		T::T(int i = 0) // This line is illegal
		  : m_i(i)
		{
		}

	It is only legal to specify default parameters in the prototype.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list