Does assembly code when used(linked) in a c project ignore const keyword declared before C datatypes and functions?? And can it modify the contents of the datatypes??
Does assembly code when used(linked) in a c project ignore const keyword declared before C datatypes and functions??
Yes, the const keyword is utterly ignored by assembly code.
And can it modify the contents of the datatypes??
If the compiler was able to place a const location in a read-only segment, then assembly code trying to modify it will cause a segmentation fault. Otherwise, unpredictable behavior will result, because the compiler may have optimized parts of the code, but not others, under the assumption that const locations were not modified.
And can it modify the contents of the datatypes??
Maybe, maybe not. If the original object was declared const then the compiler might emit it into a read-only data segment, which would be loaded into a read-only memory page at runtime. Writing to that page, even from assembly, would trigger a runtime exception (access violation or segmentation fault).
You won't receive a compile-time error, but at runtime your program might crash or behave erratically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With