Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Inline variable support in intel 19 compiler

K___Benny
Beginner
466 Views
The following code compiles and runs properly with gcc 8.2.0 (using -std=c++17).
It also compiles with icc 19.0.1.144, but throws a 'Floating point exception' when trying to access 'map' in the constructor.

#include <iostream>
#include <unordered_map>

struct A {
    static inline std::unordered_map<int, int> map;
    A(){
        map[1] = 2;
    }
};

int main(){
    A a;
}

A similar code with a primitive or 'std::vector' in place of 'std::unordered_map' does appears to work.

Am I missing something or is this a problem with the compiler?

This question was first posted here

0 Kudos
3 Replies
Viet_H_Intel
Moderator
466 Views

I've reported this problem to our Developer.  An internal case is  #CMPLRIL0-31151

Thanks,

0 Kudos
K___Benny
Beginner
466 Views

Hi,

Where can I find out if this issue was handled in newer icc versions?

Should the internal case number appear anywhere?

Apologies. I'm new to these things...

0 Kudos
jimdempseyatthecove
Honored Contributor III
466 Views

What is the purpose of the use of inline on an object?

Is this to possibly attribute inline to all the member functions?
The place for this would be inside the template(s).

Jim Dempsey

EDIT: Nevermind, I see: https://www.codingame.com/playgrounds/2205/7-features-of-c17-that-will-simplify-your-code/inline-variables

 

0 Kudos
Reply