Does clang support -fno-enforce-eh-specs option of gcc

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Does clang support -fno-enforce-eh-specs option of gcc

Dev Meetei
Hi all
is the above flag supported.
Will also appreciate if some one can tell best practices to follow while using clang for reducing size of the resultant binaries?

Warm Regards
-Dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Konstantin Tokarev
 
 
13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
Hi all
is the above flag supported.
Will also appreciate if some one can tell best practices to follow while using clang for reducing size of the resultant binaries?

Warm Regards
-Dev
,

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

--
Regards,
Konstantin

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Konstantin Tokarev
In reply to this post by Dev Meetei

13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
> Hi all
> is the above flag supported.

No.

> Will also appreciate if some one can tell best practices to follow while using clang for reducing size of the resultant binaries?

-Os -fno-rtti -fno-exceptions

--
Regards,
Konstantin
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Matthieu Monrocq


On Tue, Nov 13, 2012 at 7:44 PM, Konstantin Tokarev <[hidden email]> wrote:

13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
> Hi all
> is the above flag supported.

No.

> Will also appreciate if some one can tell best practices to follow while using clang for reducing size of the resultant binaries?

-Os -fno-rtti -fno-exceptions

--
Regards,
Konstantin


I would note that this not exactly similar:

-fno-enforce-eh-specs
    Don't check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining NDEBUG. The compiler will still optimize based on the exception specifications. 

This means that -fno-enforce-eh-specs let's you keep using exceptions.


A better alternative to `throw()` combined with `-fno-enforce-eh-specs` is `noexcept` in C++11. If you throw, you are into undefined behavior land because there is no runtime check.

I do not think there are similar alternatives when the exception specification did precise a list of exceptions, but those are much rarer.

-- Matthieu

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Dev Meetei
Thanks All

Warm regards
--Dev


On Wed, Nov 14, 2012 at 12:21 AM, Matthieu Monrocq <[hidden email]> wrote:


On Tue, Nov 13, 2012 at 7:44 PM, Konstantin Tokarev <[hidden email]> wrote:

13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
> Hi all
> is the above flag supported.

No.

> Will also appreciate if some one can tell best practices to follow while using clang for reducing size of the resultant binaries?

-Os -fno-rtti -fno-exceptions

--
Regards,
Konstantin


I would note that this not exactly similar:

-fno-enforce-eh-specs
    Don't check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining NDEBUG. The compiler will still optimize based on the exception specifications. 

This means that -fno-enforce-eh-specs let's you keep using exceptions.


A better alternative to `throw()` combined with `-fno-enforce-eh-specs` is `noexcept` in C++11. If you throw, you are into undefined behavior land because there is no runtime check.

I do not think there are similar alternatives when the exception specification did precise a list of exceptions, but those are much rarer.

-- Matthieu


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Richard Smith
In reply to this post by Matthieu Monrocq
On Tue, Nov 13, 2012 at 10:51 AM, Matthieu Monrocq
<[hidden email]> wrote:

>
>
> On Tue, Nov 13, 2012 at 7:44 PM, Konstantin Tokarev <[hidden email]>
> wrote:
>>
>>
>> 13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
>> > Hi all
>> > is the above flag supported.
>>
>> No.
>>
>> > Will also appreciate if some one can tell best practices to follow while
>> > using clang for reducing size of the resultant binaries?
>>
>> -Os -fno-rtti -fno-exceptions
>>
>> --
>> Regards,
>> Konstantin
>
>
> I would note that this not exactly similar:
>
> -fno-enforce-eh-specs
>     Don't check for violation of exception specifications at runtime. This
> option violates the C++ standard, but may be useful for reducing code size
> in production builds, much like defining NDEBUG. The compiler will still
> optimize based on the exception specifications.
>
> This means that -fno-enforce-eh-specs let's you keep using exceptions.
>
>
> A better alternative to `throw()` combined with `-fno-enforce-eh-specs` is
> `noexcept` in C++11. If you throw, you are into undefined behavior land
> because there is no runtime check.

That was true for a while when the 'noexcept' feature was being
designed, but is no longer the case. Just as a 'throw()' exception
specification calls 'std::unexpected' when an exception is thrown, a
'noexcept' exception specification calls 'std::terminate'. See C++11
[except.spec] p9.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Matthieu Monrocq


On Tue, Nov 13, 2012 at 9:15 PM, Richard Smith <[hidden email]> wrote:
On Tue, Nov 13, 2012 at 10:51 AM, Matthieu Monrocq
<[hidden email]> wrote:
>
>
> On Tue, Nov 13, 2012 at 7:44 PM, Konstantin Tokarev <[hidden email]>
> wrote:
>>
>>
>> 13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
>> > Hi all
>> > is the above flag supported.
>>
>> No.
>>
>> > Will also appreciate if some one can tell best practices to follow while
>> > using clang for reducing size of the resultant binaries?
>>
>> -Os -fno-rtti -fno-exceptions
>>
>> --
>> Regards,
>> Konstantin
>
>
> I would note that this not exactly similar:
>
> -fno-enforce-eh-specs
>     Don't check for violation of exception specifications at runtime. This
> option violates the C++ standard, but may be useful for reducing code size
> in production builds, much like defining NDEBUG. The compiler will still
> optimize based on the exception specifications.
>
> This means that -fno-enforce-eh-specs let's you keep using exceptions.
>
>
> A better alternative to `throw()` combined with `-fno-enforce-eh-specs` is
> `noexcept` in C++11. If you throw, you are into undefined behavior land
> because there is no runtime check.

That was true for a while when the 'noexcept' feature was being
designed, but is no longer the case. Just as a 'throw()' exception
specification calls 'std::unexpected' when an exception is thrown, a
'noexcept' exception specification calls 'std::terminate'. See C++11
[except.spec] p9.

Damned.

Thanks for the update.

Do you think it would make sense to implement the `-fno-enforce-eh-specs` flag then ?

-- Matthieu

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Does clang support -fno-enforce-eh-specs option of gcc

Dev Meetei
I guess that will make migration from gcc easy a bit.


On Wed, Nov 14, 2012 at 3:49 AM, Matthieu Monrocq <[hidden email]> wrote:


On Tue, Nov 13, 2012 at 9:15 PM, Richard Smith <[hidden email]> wrote:
On Tue, Nov 13, 2012 at 10:51 AM, Matthieu Monrocq
<[hidden email]> wrote:
>
>
> On Tue, Nov 13, 2012 at 7:44 PM, Konstantin Tokarev <[hidden email]>
> wrote:
>>
>>
>> 13.11.2012, 22:39, "Devchandra L Meetei" <[hidden email]>:
>> > Hi all
>> > is the above flag supported.
>>
>> No.
>>
>> > Will also appreciate if some one can tell best practices to follow while
>> > using clang for reducing size of the resultant binaries?
>>
>> -Os -fno-rtti -fno-exceptions
>>
>> --
>> Regards,
>> Konstantin
>
>
> I would note that this not exactly similar:
>
> -fno-enforce-eh-specs
>     Don't check for violation of exception specifications at runtime. This
> option violates the C++ standard, but may be useful for reducing code size
> in production builds, much like defining NDEBUG. The compiler will still
> optimize based on the exception specifications.
>
> This means that -fno-enforce-eh-specs let's you keep using exceptions.
>
>
> A better alternative to `throw()` combined with `-fno-enforce-eh-specs` is
> `noexcept` in C++11. If you throw, you are into undefined behavior land
> because there is no runtime check.

That was true for a while when the 'noexcept' feature was being
designed, but is no longer the case. Just as a 'throw()' exception
specification calls 'std::unexpected' when an exception is thrown, a
'noexcept' exception specification calls 'std::terminate'. See C++11
[except.spec] p9.

Damned.

Thanks for the update.

Do you think it would make sense to implement the `-fno-enforce-eh-specs` flag then ?

-- Matthieu

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev