Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7683 Discussions

[BUG] internal error: icc chokes on struct with function pointer

Sebastian_Freundt
234 Views
Following code:
extern struct stream_s make_stream(void);

struct stream_s {
	void *clo;
	/* for strctl */
	int(*ctl)(void*, ...);
};

struct stream_s
make_stream(void)
{
	static int x;
	return (struct stream_s){.clo = &x};
}

when compiled produces:

$ icc -std=c99 -g -O2 ./crash.c
": internal error: ** segmentation violation signal raised **
Access violation or stack overflow. Please contact Support.

compilation aborted for ./crash.c (code 4)

Interestingly, when the function pointer is the first slot in the struct the code will run just fine.

 

0 Kudos
5 Replies
Sebastian_Freundt
234 Views

Forgot to post versions:

$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

 

MalReddy_Y_Intel
Employee
234 Views

Hi,

I can also reproduce this issue, thanks for reporting. I have escalated to development team. I will inform you when I have an update.

Reddy

 

Sebastian_Freundt
234 Views

Just to let you know, icc 16.0.0.069 Beta Build 20150527 still shows this issue.

 

Sebastian_Freundt
234 Views
Just to let you know, icc 18.0.0 20170811 still shows this issue.
Judith_W_Intel
Employee
234 Views

 

Yes this bug is still open in our database (as cmplrs-626).

There are two possible workarounds, as shown below under #ifdef OK or #ifdef OK2.
The bug has to do with placing a temporary declaration which uses x before the declaration of x on the list of static variables.

extern struct stream_s make_stream(void);
struct stream_s {
void *clo;
/* for strctl */
int(*ctl)(void*, ...);
};
struct stream_s
make_stream(void)
{
#ifdef OK
int x;
#else
static int x;
#endif

#ifdef OK2
struct stream_s tmp;
tmp.clo = &x;
return tmp;
#else
return (struct stream_s){.clo = &x};
#endif
}

 

Reply