Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Interernal Compile Error when a variadic function used in a class method


This question is answered.


Permlink Replies: 3 - Last Post: Jan 26, 2017 1:07 AM Last Post By: Arkady Semylio
Akihito Yamashiro

Posts: 2
Registered: 5/25/14
Interernal Compile Error when a variadic function used in a class method  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 24, 2017 11:41 PM
I have .cpp source files in which variadic functions are used in the class methond that returns String class.
When I compile that for 32bit environment , it's OK.
But when I compile it for 64 bit environment on C++Builder XE7 , I encounter 'Internal Compile Error'.
And when I compile it for 64 bit environment on C++Builder XE4 , the IDE dies silently.
When I compile it for 64 bit environment on C++Builder 10.1 berlin, it succeeds.

Is there any workaround for the ICE on XE7 ? I must use XE7.

The minimum code to reproduce the case is the following. 'func2' is in question.

<File1.cpp>

#include <vcl.h>
#pragma hdrstop
#pragma argsused

#ifdef _WIN32
#include <tchar.h>
#else
typedef char _TCHAR;
#define _tmain main
#endif

#include <stdio.h>
#include <stdarg.h>

/*
Clang-64bit ICE
*/

class test
{
public:
int func1(int a, ... ) const
{
return 123;
}
String func2(int a, ... ) const
{
return L"abc";
}
};

String func3(int a, ... )
{
return L"abc";
}

int _tmain(int argc, _TCHAR* argv[])
{
test a;

a.func1(123, L"test");
a.func2(123, L"test"); //ICE!!
func3(123, L"test");

return 0;
}

Arkady Semylio

Posts: 87
Registered: 9/18/15
Re: Interernal Compile Error when a variadic function used in a class method
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 12:49 AM   in response to: Akihito Yamashiro in response to: Akihito Yamashiro
Akihito Yamashiro wrote:
I have .cpp source files in which variadic functions are used in the class methond that returns String class.
When I compile that for 32bit environment , it's OK.
But when I compile it for 64 bit environment on C++Builder XE7 , I encounter 'Internal Compile Error'.
And when I compile it for 64 bit environment on C++Builder XE4 , the IDE dies silently.
When I compile it for 64 bit environment on C++Builder 10.1 berlin, it succeeds.

Is there any workaround for the ICE on XE7 ? I must use XE7.

I don't have XE7 but on the XE8 this ICE persists. As I noticed that the problem
comes from the fact that func2 return a complex type (like String), but it
disappear as soon as you declare func2 static, there's an ugly workaround
(quick and dirty) that could help; the following:

#include <vcl.h>
#pragma hdrstop
#pragma argsused
 
#ifdef _WIN32
#include <tchar.h>
#else
  typedef char _TCHAR;
  #define _tmain main
#endif
 
#include <stdio.h>
#include <stdarg.h>
 
/*
  Clang-64bit ICE
*/
 
class test
{
public:
	int func1(int a, ... ) const
	{
		return 123;
	}
 
	static String func2( test& This, int a, ... )
	{
                 This.av = a;  // E.g., accessing a private data member from a static function
                 return L"123";
	}
private:
    int av;
};
 
String func3(int a, ... )
{
	return L"abc";
}
 
 
 int _tmain(int argc, _TCHAR* argv[])
{
	test a;
 
	a.func1(123, L"test");
	//func2(123, L"test"); 		//ICE!!
 
        // Explicitly pass the object as 1st parameter
	test::func2(a, 123, L"test"); 	
 
	func3(123, L"test");
 
	return 0;
}


HTH

Bye bye
Akihito Yamashiro

Posts: 2
Registered: 5/25/14
Re: Interernal Compile Error when a variadic function used in a class method  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 25, 2017 8:09 PM   in response to: Arkady Semylio in response to: Arkady Semylio
Thank you , Arkady , for your replying.
The workaround worked very well. How simple it is! I'm so glad to be taught this solution.
As you've said , though it's dirty , but it's very simple to use.
I appreciate it so much!
Arkady Semylio

Posts: 87
Registered: 9/18/15
Re: Interernal Compile Error when a variadic function used in a class method  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 1:07 AM   in response to: Akihito Yamashiro in response to: Akihito Yamashiro
Akihito Yamashiro wrote:
The workaround worked very well. How simple it is! I'm so glad to be taught this solution.
As you've said , though it's dirty , but it's very simple to use.
I appreciate it so much!

You're welcome.

:)

Bye bye
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02