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

access violation error when compiling specific source code

mengke_e_
Beginner
296 Views

Hi everyone!

I got this issue when compiling my code, and I have minimized it into a several-line demonstration:

struct Obj
{
    Obj() = default;
    Obj( const Obj& ) = default;
    Obj& operator=( const Obj&) = default;
    ~Obj() = default; // <-- delete this fun and everything works. but how??
};

template <typename Type>
class TestType
{
public:
    void foo( Type valueToCompare ) {}
};


int main()
{
    TestType<Obj> obj;
    obj.foo(  Obj() );
    return 1;
}

This would cause a "error : access violation void foo( Type valueToCompare ) {}" during compiling. And if you remove the default destructor specification, the error would mysteriously disappear.

I'm using ICC 2015 update 4.

0 Kudos
2 Replies
Shenghong_G_Intel
296 Views

Hi mengke,

I cannot reproduce the issue.

Could you please provide more information? You are using Windows right? What is the VS version? Is there any special options setup?

I've tested it on Linux with 2015 U3 and 2016 initial release, on windows with 2015 U4 (get other issues with VS2015, but that is known issues) and 2016 initial release in VS2015.

Thanks,

Shenghong

0 Kudos
Bernard
Valued Contributor I
296 Views

>>>This would cause a "error : access violation void foo( Type valueToCompare ) {}" during compiling. And if you remove the default destructor specification, the error would mysteriously disappear.>>>

I have also seen similar errors stating "access violation" when compiler stopped and was not able to compile the code. Fixing the code would help usually in my case.

0 Kudos
Reply