BSDF_CONDUCTOR has a effective value of 32(1<<5).
so we are doing all operation on flags reletive to this 5th bit only.But actually flag is a 32 bit uint and its value depends on the values at other bit positions.
in set flag you do type|BSDF_CONDUCTOR which definitely sets 5th bit of flag but other bits remain unchanged,resulting in a random number.
I hope it is clear.
Yes, I understand, maybe I was not clear enough.
Set a flag : type = type|BSDF_CONDUCTOR
Reset all and set a specific flag : type = BSDF_CONDUCTOR
In general, it's a good idea to wrap such defines with a paranthesis, like
#define BSDF_TRANSMISSION (1<<1)
#define BSDF_ALL_TYPES (BSDF_DIFFUSE | BSDF_GLOSSY | BSDF_SPECULAR)
Although I don't think that's the problem in your code, assuming you listed all the operations you use.
However, there is a potential for operator precedence effects to create really obscure bugs if you don't make sure the define is evaluated in its entirety before any outside operations can operate on the content.