Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Manodeep_s_
Beginner
124 Views

Compiler error while creating an union (icc15, icc14, icc13)

We ran into this internal compiler error with our open source code, described here: https://github.com/manodeep/Corrfunc/issues/100. We have fixed it for the repo but figured it might be helpful for the compiler developers.

Thanks to the efforts of Lehman Garrison (github: @lgarrison), here is a minimum failing example:

#include <immintrin.h>
#include <stdio.h>
#include <stdint.h>

#define MAX_NUM_WEIGHTS 10

typedef union {
    __m256d a;
    double d;
} weights_union;

typedef struct
{
    int64_t num_weights;
    weights_union weights0[MAX_NUM_WEIGHTS];
    weights_union dx;
} pair_struct;

int main(void){
    int64_t num_weights = 0;
    pair_struct pair = {.num_weights = num_weights,
                       .dx.d=0.
                       };

    return 0;
}

Compiling with "icc -std=c99 -Wall test.c -o test" causes the following error:

": internal error: ** The compiler has encountered an unexpected problem.
** Segmentation violation signal raised. **
Access violation or stack overflow. Please contact Intel Support for assistance.

icc --version

icc (ICC) 15.0.2 20150121
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

 

 

Swapping num_weights and weights0 in the pair_struct solves the problem. As @lgarrison noted in the github issue, the ICE must be related to alignment requirements.

Please let me know if you need any further info.

 

Thanks,

Manodeep Sinha

 

 

 

 

 

0 Kudos
4 Replies
TimP
Black Belt
124 Views

$ icl -Qstd=c99 -Wall ms.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

ms.c
ms.c(21): remark #177: variable "pair" was declared but never referenced
      pair_struct pair = {.num_weights = num_weights,
                  ^

": internal error: ** The compiler has encountered an unexpected problem.
** Segmentation violation signal raised. **
Access violation or stack overflow. Please contact Intel Support for assistance.


compilation aborted for ms.c (code 4)

Viet_H_Intel
Moderator
124 Views

It seems to be a compiler bug. I'l work on it and keep you posted.

Thanks,

Viet

Viet_H_Intel
Moderator
124 Views

Hi Manodeep,

I have reported this issue to our developer. The tracker is DPD200415977.

Thanks,

Viet

Manodeep_s_
Beginner
124 Views

Thanks!

Reply