Hi!

On 2022-11-09T14:53:44+0100, Richard Biener via Gcc-patches 
<gcc-patches@gcc.gnu.org> wrote:
> On Wed, Oct 26, 2022 at 10:37 AM <arthur.co...@embecosm.com> wrote:
>> This patch [...] also contains a constant evaluator, ported
>> over from the C++ frontend.

Given that, and then:

>> --- /dev/null
>> +++ b/gcc/rust/backend/rust-constexpr.cc

>> +struct constexpr_global_ctx
>> +{
>> +  HOST_WIDE_INT constexpr_ops_count;
>
> If this isn't a INTEGER_CST related value then please avoid HOST_WIDE_INT
> and instead use uint64_t (or other more appropriate types).
>
>> +
>> +  constexpr_global_ctx () : constexpr_ops_count (0) {}
>> +};
>> +[...]
>> +static tree
>> +constexpr_expression (const constexpr_ctx *ctx, tree t)
>> +{
>> +  [...]
>> +  // Avoid excessively long constexpr evaluations
>> +  if (++ctx->global->constexpr_ops_count >= constexpr_ops_limit)
>> +    {
>> +      rust_error_at (
>> +       Location (loc),
>> +       "%<constexpr%> evaluation operation count exceeds limit of "
>> +       "%wd (use %<-fconstexpr-ops-limit=%> to increase the limit)",
>> +       constexpr_ops_limit);
>> +
>> +      return t;
>> +    }

Arthur thus turned the 'HOST_WIDE_INT constexpr_ops_count' into an
'unsigned long', see <https://github.com/Rust-GCC/gccrs/pull/1661>
"58e75f65e56d: Remove HOST_WIDE_INT struct member", but that results in
GCC bootstrap failure:

    [...]/source-gcc/gcc/rust/backend/rust-constexpr.cc: In function 
‘tree_node* Rust::Compile::constexpr_expression(const constexpr_ctx*, tree)’:
    [...]/source-gcc/gcc/rust/backend/rust-constexpr.cc:99:42: error: 
comparison of integer expressions of different signedness: ‘long unsigned int’ 
and ‘long int’ [-Werror=sign-compare]
       99 |   if (++ctx->global->constexpr_ops_count >= constexpr_ops_limit)

See the original C++ code:

    gcc/cp/constexpr.cc:  HOST_WIDE_INT constexpr_ops_count;

    gcc/c-family/c.opt-fconstexpr-ops-limit=
    gcc/c-family/c.opt:C++ ObjC++ Joined RejectNegative Host_Wide_Int 
Var(constexpr_ops_limit) Init(33554432)
    gcc/c-family/c.opt--fconstexpr-ops-limit=<number>       Specify maximum 
number of constexpr operations during a single constexpr evaluation.

So I suggest change back the GCC/Rust 'constexpr_ops_count' to
'HOST_WIDE_INT' (submitted <https://github.com/Rust-GCC/gccrs/pull/1666>
'Revert #1661 "58e75f65e56d: Remove HOST_WIDE_INT struct member"'), and
if anything needs to be changed, do thatt in GCC/C++ first, and then
mirror that into GCC/Rust.


Grüße
 Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955

Reply via email to