This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Resurrecting -Wunreachable


On Wed, May 7, 2014 at 2:07 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 05/07/2014 02:04 PM, Richard Biener wrote:
>
>> Depends on what "trivially" unreachable is.  Yes,
>>
>> int main()
>> {
>>    if (0)
>>      foo ();
>> }
>>
>> will already be optimized.  But I doubt you want to warn for that
>> given C++ and templates which often have this kind of specializations.
>
>
> Precisely.  But optimizing this:
>
>
> int main()
> {
>    if (0)
>      foo ();
>    else
>      throw std::logic_error ("error");
>    bar ();
> }
>
> to:
>
> int main()
> {
>    throw std::logic_error ("error");
>    bar ();
> }
>
> would cause the code to issue such unwanted warnings.  That's why I need
> access to these trivial if statements.

I don't think it would.  bar () would be gone already as throw doesn't return.

Richard.

>
> --
> Florian Weimer / Red Hat Product Security Team


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]