[ 
https://issues.apache.org/jira/browse/STDCXX-998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Sebor reassigned STDCXX-998:
-----------------------------------

    Assignee: Martin Sebor

> add throw() exception specification to all non-throwing functions
> -----------------------------------------------------------------
>
>                 Key: STDCXX-998
>                 URL: https://issues.apache.org/jira/browse/STDCXX-998
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Build and Installation
>    Affects Versions: 4.2.1
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>            Priority: Critical
>             Fix For: 4.2.2
>
>         Attachments: uninit_fill.ipf.s, unint_fill_nothrow.ipf.s
>
>   Original Estimate: 6h
>  Remaining Estimate: 6h
>
> When a compiler cannot determine whether a function declared without an 
> explicit exception specification may throw an exception or not (e.g., because 
> the compiler/optimizer doesn't have access to the definition of the function) 
> it must assume that the function may throw and may need to generate 
> suboptimal code as a result.
> Compilers often assume that even inline functions that can be proven not to 
> throw exceptions may throw unless they are declared with the empty exception 
> specification and generates suboptimal code as a result. For example, HP aCC 
> 6 assumes that {{S::S()}} in the code below may throw
> and fails to optimize the catch block away, generating object code 2.5 times 
> the size bigger than necessary. (Note that gcc 3.4 on IPF generates optimal 
> code in this case).
> To help compilers generate optimal code we should make use of the empty 
> exception specification on all functions that cannot throw exceptions, 
> including those declared explicitly or implicitly {{inline}}.
> {code}
> #include <new>
> struct S {
>     int i;
>     S () /* throw () */: i () { }
> };
> void uninit_fill (S *a, S *b)
> {
>     S *p = a;
>     try {
>         for ( ; p != b; ++p)
>             new (p) S ();
>     }
>     catch (...) {
>         while (p-- != a)
>             p->~S ();
>         throw;
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to