This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/10223: template trickery causes ICE (segmentation fault)


>Number:         10223
>Category:       c++
>Synopsis:       template trickery causes ICE (segmentation fault)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 26 14:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Geza Herman
>Release:        All gcc versions
>Organization:
>Environment:
Linux 2.4.18 i686 Debian GNU/Linux
>Description:
The code sample causes ICE an all gcc versions I tried:
gcc version 2.95.4 20011002 (Debian prerelease)
gcc version 3.0.4
gcc version 3.2.3 20030316 (Debian prerelease)
gcc version 3.3 20030314 (prerelease)

The sample tries to get some meta-information: tries to determine if a class has a particular member-function.
('void save()' in this example)
>How-To-Repeat:
compile this sample:

template <typename T>
class hasSaveFunction {
	private:
		struct Helper {
			struct False { char dummy[1979]; };

			template <void (T::*)()>
			struct dummy;

			template <typename T2>
			static char test(dummy<&T2::save> *);

			template <typename T2>
			static False test(...);
		};

	public:
		static const bool value = sizeof(Helper::template test<T>(0))==1
;
};

class Dummy { };

int main() {
	return hasSaveFunction<Dummy>::value;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]