Possible disadvantages of compiling with / unsafe

I need to compile my assembly with / unsafe in order to use a pointer. I wonder when I compile / insecurely. Suppose there are no programming errors, such as improper use of pointers, etc. Can I lose some performance if I use an unsafe compiled assembly? Any memory flaws?

+4
source share
2 answers

Well, using "unsafe" code, you basically improve performance, with memory access and pointer arithmetic. A common use case for this is inside high-performance .NET code, such as 3D kernel rendering. Writing such files in 100% .NET code will make the application too slow, so pointers come to the rescue, especially when we need to deal with "bridges" between C/C++ libriaries, like OpenGL (let's say)

In short: you will benefit from this, definitely if you write good unmanaged code.

+3
source

Insecure code can increase application performance by removing array bounds checks.

Using unsafe code leads to security and stability risks.

Link: http://msdn.microsoft.com/en-us/library/chfa2zb8.aspx

+1
source

Source: https://habr.com/ru/post/1434600/


All Articles