From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id 7EE09383982E for ; Fri, 8 Apr 2022 14:58:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EE09383982E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f41.google.com with SMTP id w4so13208920wrg.12 for ; Fri, 08 Apr 2022 07:58:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=p80ex2C9Q83hCUG99e7vjxrcZYLiZ3z0ZeATKYdNw9A=; b=ePjiQIrmxTKDB++++1jHJ/QZFkjbXTztVZQWbJ9KyymHmliji+AsYfCTcCAQhPza0F 6yk1YIF07Gl2+qBnjqwgJYXq7i41fnRTaMHlJeuQv7vztyIG8svM2XJB0zw4bzyP0811 VcdqjCZE5/DGmM248w9Z3sWaeiNgVjFEmBks0mizqhbG2twgEI2La0/7Y1a8kd5hfS3N ZGYsmAObA3QCnXaAnYbr8ENbRBRWeLigOU0Xx9YYUGqAlLKqGom9c60CrE8NSUmCJAlr uDQWsO2BafXtYpwig7xZofUtQnY9e3XZmG+0l8kDkhQpApS0QcTqrmXChcsEQbIfax5S HB1Q== X-Gm-Message-State: AOAM531GYMTd5oWPnlBW78N6KwK9VBvVY78Po6a/rQ9uSiogvpey4a8k yC/JvQufohoRsspgmYil/RoqW2kpHD8= X-Google-Smtp-Source: ABdhPJxssoUepMNh4TyXZD+aq3q5dlj0acxGEXGUb4wwayIt41oRjkvZUlm3sQrXEpR6S1P0jLi/gQ== X-Received: by 2002:a5d:47cc:0:b0:204:1c9d:2157 with SMTP id o12-20020a5d47cc000000b002041c9d2157mr14675971wrc.294.1649429899203; Fri, 08 Apr 2022 07:58:19 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id d14-20020a056000186e00b0020405198faasm23032513wri.52.2022.04.08.07.58.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Apr 2022 07:58:16 -0700 (PDT) Message-ID: Date: Fri, 8 Apr 2022 15:58:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 1/2] Fix undefined behavior in the Fortran, Go and Pascal number parsers Content-Language: en-US To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20220407200617.2947845-1-pedro@palves.net> <20220407200617.2947845-2-pedro@palves.net> <87v8vj7hxx.fsf@tromey.com> From: Pedro Alves In-Reply-To: <87v8vj7hxx.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2022 14:58:22 -0000 On 2022-04-08 15:44, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> This commit ports these two fixes to the C parser: > > Pedro> ... to the Fortran, Go, and Fortran number parsers, fixing the same > Pedro> problems there. > > If the code is all the same (I didn't check), maybe it should just be > merged into a single spot. It's fine by me if you don't want to, though. A lot of it looks the same on the surface, but there are important differences. For example, the builtin types are different, like: putithere->typed_val_float.type = builtin_go_types->builtin_float32; each parser's YYSTYPE is going to be a different type, and then different languages parse different suffixes or features. E.g., not all support complex numbers. go-exp.y has this comment: /* FIXME(dje): IWBN to use c-exp.y's parse_number if we could. That will require moving the guts into a function that we both call as our YYSTYPE is different than c-exp.y's */ C++ templates nowadays may help here for the YYSTYPE type, not sure. I had looked at bit into this, but quickly decided it would be a lot more effort than I'd wanted to spend here. > > Pedro> diff --git a/gdb/go-exp.y b/gdb/go-exp.y > Pedro> index 456920456cd..07943b1c8c3 100644 > Pedro> --- a/gdb/go-exp.y > Pedro> +++ b/gdb/go-exp.y > Pedro> @@ -649,8 +649,8 @@ parse_number (struct parser_state *par_state, > Pedro> { > Pedro> /* FIXME: Shouldn't these be unsigned? We don't deal with negative values > Pedro> here, and we do kind of silly things like cast to unsigned. */ > Pedro> - LONGEST n = 0; > Pedro> - LONGEST prevn = 0; > Pedro> + ULONGEST n = 0; > Pedro> + ULONGEST prevn = 0; > > The comment can be removed now. I think you just forgot this spot since > you did remove it in p-exp.y. Thanks. I'll fix this and merge this one.