From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2765479D2 for ; Sun, 5 May 2024 16:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714926490; cv=none; b=nxHkUAd4ApARkR952QFlvtMZwX0uJsnVCgLLigIyoajVDzPlq9dIN9GGIfwm6tJ1y5zV2KmjavEB8fBpzbLhBzjFtndslx3UFq/me1Wv5rD+Q/4O20G4nnTU/8sy+5jkojKNlOLqMyuoj07qTStakJFccVGsfzdOH+vGQ//WXsc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714926490; c=relaxed/simple; bh=/ioVNCWeLP3MxACn6fQ9hhOVwLYyvVT0BspUopkUCCc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=IornknWayzqExMZJ2xTorb7i4wxDgVn7YQ/OQbyB92qPXTJg1o39PCZTYYDVEEYecHbgg/Ebv+kKDZDiA1Bqx70DguYWFO92wE/jvXdrwGQWq7As0w+WhLNuMGWzk0aiVe8VpRvY3dEEdYfkeV8H+IiImorbFxPvK+2+zfv7S/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oSI5w8Tg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oSI5w8Tg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7F6CC113CC; Sun, 5 May 2024 16:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714926489; bh=/ioVNCWeLP3MxACn6fQ9hhOVwLYyvVT0BspUopkUCCc=; h=Date:From:To:Cc:Subject:From; b=oSI5w8TgOrONEnI9niYe4BrPevS75X13x69ZdcB024BODMMD9rSnM9Ck081Ge08/Z 5aSPDRHf8gsG9bFbRYIzeXiRH0UE0QXlmlhxGwey7R+HA1+N7EPHX/Qea2i6UlJzn7 adHe86/RaAqqIjNiiKyo308KlYR45EMq2tQJLYtMspuXsYnx/2qavaAs7SJYDuDcpp b1yEtTer9MoJTDnWd9eU6fnBL63hLIvXk1Fu1/NqbJZ1LdeDgwkz1nlL+MXe8GAFHr dEQnoCmnZo4/RE45rAt89tBDZTAY/1ZwjmrYQTXNt9gHCRs7wJJmUMmkxCPBr7LDbU UyF1iKOr5WFqw== Date: Sun, 5 May 2024 18:28:06 +0200 From: Alejandro Colomar To: daniel.marjamaki@gmail.com Cc: liba2i@lists.linux.dev Subject: cppcheck(1) internalAstError Message-ID: Precedence: bulk X-Mailing-List: liba2i@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="c/aT7tCNVvw5tLz1" Content-Disposition: inline --c/aT7tCNVvw5tLz1 Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Sun, 5 May 2024 18:28:06 +0200 From: Alejandro Colomar To: daniel.marjamaki@gmail.com Cc: liba2i@lists.linux.dev Subject: cppcheck(1) internalAstError Hi Daniel, I'm reporting a bug in cppcheck(1). Since I find the method to report bugs a bit cumbersome (requesting an account, ...), I'm sending it to the mailing list of the project where I found the bug. Feel free to open an account for me at your place if you find it appropriate, and also feel free to forward this bug report there. I'm using the cppckech(1) that ships with Debian Sid: $ cppcheck --version Cppcheck 2.14.0 And found a new error in my code after recent changes, which otherwise seem to be fine, since it builds, and all the tests pass. $ make lint-c-cppcheck --debug=3Dprint CPPCHECK .tmp/a2i/strtoi.c.lint-c.cppcheck.touch cppcheck --enable=3Dall --error-exitcode=3D2 --inconclusive --check-level= =3Dexhaustive --quiet -D__GNUC__ -D__STDC_VERSION__=3D202000L --suppression= s-list=3D./etc/cppcheck/cppcheck.suppress -I ./include lib/src/a2i/strtoi.c lib/src/a2i/strtoi.c:120:5: error: Syntax Error: AST broken, 'if' doesn't = have two operands. [internalAstError] if (a2i_strtoi(s, endp, base, 0, 1, status) =3D=3D 0 && *status =3D=3D ER= ANGE) ^ make: *** [/home/alx/src/alx/liba2i/main/share/mk/lint/c/cppcheck.mk:39: .= tmp/a2i/strtoi.c.lint-c.cppcheck.touch] Error 2 The file is below, although you may need the entire project (for the includes, ...). Feel free to try the repo: I'm having this problem at commit f7e09a7d41cd ("etc/cpplint/cpplint.cfg: Add -readability/casting"). Have a lovely day! Alex --- alx@debian:~/src/alx/liba2i/main$ cat lib/src/a2i/strtoi.c // SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar // SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception #include #include #include #include #include #include #include #define a2i_strtoI(TYPE, s, endp, base, min, max, status) = \ ({ = \ char *s_ =3D s; \ char **endp_ =3D endp; \ int base_ =3D base; \ TYPE min_ =3D min; \ TYPE max_ =3D max; \ int *status_ =3D status; \ = \ int errno_saved_, st_; \ char *e_; \ TYPE n_; \ = \ if (endp_ =3D=3D NULL) \ endp_ =3D &e_; \ if (status_ =3D=3D NULL) \ status_ =3D &st_; \ = \ if (base !=3D 0 && (base_ < 2 || base_ > 36)) { \ *status_ =3D EINVAL; \ n_ =3D 0; \ = \ } else { \ errno_saved_ =3D errno; \ errno =3D 0; \ n_ =3D _Generic((TYPE) 0, \ intmax_t: strtoimax, \ uintmax_t: strtoumax \ )(s_, endp_, base_); \ = \ if (*endp_ =3D=3D s_) \ *status_ =3D ECANCELED; \ else if (errno =3D=3D ERANGE || n_ < min_ || n_ > max_) \ *status_ =3D ERANGE; \ else if (**endp_ !=3D '\0') \ *status_ =3D ENOTSUP; \ else \ *status_ =3D 0; \ = \ errno =3D errno_saved_; \ } \ MAX(min_, MIN(max_, n_)); \ }) #if defined(__clang__) # pragma clang assume_nonnull begin #endif #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" intmax_t a2i_strtoi_c(const char *s, const char **a2i_nullable restrict endp, int base, intmax_t min, intmax_t max, int *a2i_nullable restrict status) { return a2i_strtoi((char *) s, (char **a2i_nullable) endp, base, min, max, status); } uintmax_t a2i_strtou_c(const char *s, const char **a2i_nullable restrict endp, int base, uintmax_t min, uintmax_t max, int *a2i_nullable restrict status) { return a2i_strtou((char *) s, (char **a2i_nullable) endp, base, min, max, status); } uintmax_t a2i_strtou_noneg_c(const char *s, const char **a2i_nullable restrict endp, int base, uintmax_t min, uintmax_t max, int *a2i_nullable restrict status) { return a2i_strtou_noneg((char *) s, (char **a2i_nullable) endp, base, min, max, status); } #pragma GCC diagnostic pop intmax_t (a2i_strtoi)(char *s, char **a2i_nullable restrict endp, int base, intmax_t min, intmax_t max, int *a2i_nullable restrict status) { return a2i_strtoI(intmax_t, s, endp, base, min, max, status); } uintmax_t (a2i_strtou)(char *s, char **a2i_nullable restrict endp, int base, uintmax_t min, uintmax_t max, int *a2i_nullable restrict status) { return a2i_strtoI(uintmax_t, s, endp, base, min, max, status); } uintmax_t (a2i_strtou_noneg)(char *s, char **a2i_nullable restrict endp, int base, uintmax_t min, uintmax_t max, int *a2i_nullable restrict status) { int st; if (status =3D=3D NULL) status =3D &st; if (a2i_strtoi(s, endp, base, 0, 1, status) =3D=3D 0 && *status =3D=3D ERA= NGE) return min; return a2i_strtou(s, endp, base, min, max, status); } #if defined(__clang__) # pragma clang assume_nonnull end #endif --=20 --c/aT7tCNVvw5tLz1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmY3s5YACgkQnowa+77/ 2zIOPQ/+M3BnVfVzZzwFAc0CYDyGXLfyC1kRuxCZ7crrjF4oOWaSoWIQjAmZsXWU uNGCa3UDvxlno4fRDLOGsI9SWy/pSorO7y22uZlq7dorFiHqmAir7jhpcMvGnYl3 U7l81eGxNvcxlPO6cezutmDZYH1H/g75To921KjXiV7FoKM9ROtYklfCkVz1RcJN f8MfIQaBZFCtssgtKLQBOsySirI4LkKINW1Hxe016+lEPlaVuOCXZbstaHIFmyiI Ebcj+Ppq/l38kTLtVDKgzHDXFC/nXYDGRrPUuT0tbectSsaBqU5JMk3M6Yq90AJP lZD0gAHFslPjfoMMnKT4vxbAsJ6SCLM4wP+I93wCVVpJMTumZEvHb1K4ZmASl0Cn MrHXkdAFo/OqQAP112VR3bWGElNziM3pCfcSau2Q+LxI0SVQyBNbTJAyeD/DTYOW YLtrl9AOPdtz6+yRud3LkiRhvpdjciLsUHMGXYk0PFKgRDRp2SP3bL/7psFcPNkL NvYMN7gD9IuAUI5iQCTbLouR3+VXTUnuYWpAC5aBy39VB481J343Ekwa+/WjdCrP dRHGSU7RwuY6qu347TR9onW2wfdtb+48iX/uXBWKIQUp90zx7cRS0EuvNnCxXA+K y6Ww7lcFRcRJJUrrBVwXvbWG/K+9FuHneV/B3ABWLLbO3rIs7OM= =P5xj -----END PGP SIGNATURE----- --c/aT7tCNVvw5tLz1--