assigning float into int variable causes no warning

Since you confirmed your compiler is gcc then you can use the -Wconversion flag which should provide a warning similar to this:

warning: conversion to 'int' alters 'double' constant value [-Wfloat-conversion]
i = 12.1234;
    ^

Converting a floating point value to int is perfectly valid it will discard the fractional part and as long as the value can be represented, otherwise you have undefined behavior. The C99 draft standard covers this in section 4.9 Floating-integral conversions:

A prvalue of a floating point type can be converted to a prvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type.


A float value can be assigned to an integer variable but an implicit conversion occurs when compiler forces a float value to be assigned as an integer.

The digits after the decimal notation in the float value get lost after assigning a float to an integer.

Edit: casting -> conversion

Thanks R..