Optimization and template parms
Jeffrey A Law
law@cygnus.com
Mon Feb 2 13:29:00 GMT 1998
In message < Pine.GSO.3.92.980202142024.10958D-100000@johnson.cs.nyu.edu >you w
rite:
> Hi,
>
> In the following method of a templated class:
>
> template <bool c>
> Foo<c>::f1() {
> if (c) {cout << "true" << endl;}
> else {cout << "false" << endl;}
> }
>
> Would I be correct to assume that after instantiating the template,
> egcs wouldn't emit any code for the if/else test because the test always
> succeeds for Foo<true> and fails for Foo<false>?
That would be my expectation. But I don't know enough about C++ to know how
it will look in RTL when the optimizers get their first crack at removing the
unreachable code.
jeff
More information about the Gcc
mailing list