segmentation fault while calling a C function from assembly code to print floating point values. The C function employs a switch statement to handle different data types, including doubles.printf function when handling double values, as converting the double to an integer before printing works correctly. But directly printing the double using %f results in a segmentation fault.

alignment issue or possibly an issue with how the double is being accessed in memory. When you cast a long to a double, there’s a chance that the address isn’t properly aligned for accessing double-precision floating point numbers, especially on a 64-bit system.val is aligned correctly before casting it to a double. You can add an assertion to check the alignmentassertion fails, then the address val isn’t properly aligned for a double, which would cause the segmentation fault.val is being passed from the assembly code. If there's any chance that it’s being misaligned before it’s passed to the C function.