Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
15 Views

access violation error when compiling specific source code

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
Highlighted
15 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
Highlighted
Black Belt
15 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