Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7569 Discussions

Inline variable support in intel 19 compiler

K___Benny
Beginner
158 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
158 Views

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

Thanks,

K___Benny
Beginner
158 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...

jimdempseyatthecove
Black Belt
158 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-var...

 

Reply