Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stupid compiler signs my fast uint's

Name: Anonymous 2009-04-08 16:11

Hello /prog/riders.
I've stumbled upon a problem when I tried to OPTIMIZE a topologic sort function for a geometry package. Here's the gist of it:
extern "C"
{
#include <stdint.h>
}

enum {LEFT = 1u, RIGHT = 2u, BOTH = 3u};

int main()
{
    bool side  = true;
    const bool side_const = true;

    uint_fast8_t n;

    const uint_fast8_t a = side  ? LEFT : RIGHT,
                       b = LEFT;
    const uint_fast8_t A = side_const ? LEFT : RIGHT,
                       B = LEFT;

    uint_fast8_t c = side ? LEFT : RIGHT,
                 d = LEFT;
    uint_fast8_t C = side_const  ? LEFT : RIGHT,
                 D = LEFT;

    n |= a; // warning: conversion to ‘uint_fast8_t’ from ‘int’ may alter its value
    n |= b;
    n |= A;
    n |= B;

    n |= c; // warning: conversion to ‘uint_fast8_t’ from ‘int’ may alter its value
    n |= d; // warning: conversion to ‘uint_fast8_t’ from ‘int’ may alter its value
    n |= C; // warning: conversion to ‘uint_fast8_t’ from ‘int’ may alter its value
    n |= D; // warning: conversion to ‘uint_fast8_t’ from ‘int’ may alter its value

}

As you can see the compiler evaluated the expressions for b,A and B and didn't complain about type conversion. Why then, does it need to convert my fast uints to slow ints in the case of a,c,d,C and D?
I compiled with
$ gcc -std=c++98 -Wconversion bittwiddling.cpp.
My compiler version is
$ gcc -V
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)

Name: Anonymous 2009-04-10 10:35

>>18
Look at the ASM output dumbass.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List