Re: gcc vs g++ warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Martin Ettl" <ettl.martin@xxxxxx> writes:

> compiled my application with gcc-4.3.3 on Ubuntu Linux. I also compiled it with g++-4.3.3 and got the following issue.
>
> I created the following testcase:
>
> #define SR_MULT (11*12)
> #define A(x) (x) ? (SR_MULT/x) : 0
> static const unsigned char sr_adc_mult_table[] = {
>     A(2), A(2), A(12), A(12),  A(0), A(0), A(3), A(1),
>     A(2), A(2), A(11), A(11),  A(0), A(0), A(0), A(1)
> };
>
> int main()
> {}
>
>
> My compiler says:
>
> $ g++ -o test test.cpp 
> test.cpp:4: warning: division by zero
> test.cpp:4: warning: division by zero
> test.cpp:5: warning: division by zero
> test.cpp:5: warning: division by zero
> test.cpp:5: warning: division by zero

...

> gcc does not warn about this. What happens, is this a bug in the compiler?

I'm not sure that I would call it a bug, exactly.  It's more of a
missing feature in the C++ frontend.  When the C frontend sees code like
    0 ? (121 / 0) : 0
it suppresses certain warnings about in the "(121 / 0)" part, since that
will never be executed.  The C++ frontend does not have that feature.
Coincidentally, I just proposed a patch to fix this in the C++ frontend.
    http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01001.html

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux