Consider below C program.
If we call as “func()”it will return constant 1. But it is also possible to call the function as “func((double *)&a)” which was supposed to return 1 but returning something else. The code was made to return constant 1 only! That’s a big problem but STRICT ALIASING fixes it.
Use restrict qualifier keyword. It means you promise the compiler that something is not aliased with the pointer restrict keyword. If you break your promise you will only suffer. Please refer restrict keyword in C for details.
- Namespace in C++ | Set 3 (Accessing, creating header, nesting and aliasing)
- Else without IF and L-Value Required Error in C
- time.h header file in C with Examples
- __builtin_inf() functions of GCC compiler
- Count substrings that contain all vowels | SET 2
- How can we use Comma operator in place of curly braces?
- Basic Code Optimizations in C
- Constants vs Variables in C language
- Sum of an array using MPI
- Difference between pointer to an array and array of pointers
- dot (.) operator in C/C++
- Features and Use of Pointers in C/C++
- Difference between while and do-while loop in C, C++, Java
- C program to sort an array using pointers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.