cassemblyconstants

Does assembly code ignore const keyword?


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??


Solution

  • 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.