GCC conversion warning when assigning to a bitfield
问题 Is there any way to supress the warning generated by gcc in this code: int main() { struct flagstruct { unsigned flag : 1; } a,b,c; a.flag = b.flag | c.flag; return a.flag; } The warning is warning: conversion to 'unsigned char:1' from 'int' may alter its value [-Wconversion] It looks like the the two flags are extended to int when ored together. What I think is really strange is that casting any of the two flags to unsigned supresses the warning. a.flag = (unsigned)b.flag | c.flag; Is this a