From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 241EB385842A; Mon, 22 Jan 2024 18:06:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 241EB385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705946782; bh=IOI3Daq5buRwqyMWNG9YKIqFJXEYVh/JqKHCgQ8QX7Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ezCfr518ef76UDrAhCSbwGsKTgiiCj0QdHh9ru+/hPDd1QQpIjcoyobtJeQUBQU+H 4gpYHbI9WPRo5SkHYhnxWgJx+7ECzVEFZiG/r3a81LUY8CbyWabvukrDL0fF8X3Wze 5MnmJikMEput12A6d2+nAIRW2j1XTtmflfy+bT+o= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113152] Fortran 2023 half-cycle trigonometric functions Date: Mon, 22 Jan 2024 18:06:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113152 --- Comment #17 from Steve Kargl = --- On Mon, Jan 22, 2024 at 05:35:41PM +0000, anlauf at gcc dot gnu.org wrote: > --- Comment #16 from anlauf at gcc dot gnu.org --- > (In reply to Steve Kargl from comment #14) > > On Sun, Jan 21, 2024 at 09:52:39PM +0000, anlauf at gcc dot gnu.org wro= te: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113152 > > >=20 > > > I think that you cannot do > > >=20 > > > + if (MPFR_HALF_CYCLE) > > >=20 > > > you really must use > > >=20 > > > #if MPFR_HALF_CYCLE > > >=20 > >=20 > > #include > > #include "mpfr.h" > >=20 > > #define MPFR_HALF_CYCLE (MPFR_VERSION_MAJOR * 100 + MPFR_VERSION_MINOR = >=3D > > 402) > >=20 > > int > > main(void) > > { > > if (MPFR_HALF_CYCLE) > > printf("here\n"); > > else > > printf("there\n"); > > return (0); > > } > >=20 > > % cc -o z -I/usr/local/include a.c && ./z >=20 > This does not test the right thing. >=20 > % cat sgk.cc > #include >=20 > #define MPFR_HALF_CYCLE 0 This is not what the pre-processor should be doing (on at least FreeBSD). See below. > int > main(void) > { > if (MPFR_HALF_CYCLE) > printf_not_declared_if_0 ("here\n"); > else > printf ("there\n"); > return (0); > } >=20 > % g++ sgk.cc > sgk.cc: In function 'int main()': > sgk.cc:9:7: error: 'printf_not_declared_if_0' was not declared in this sc= ope > printf_not_declared_if_0 ("here\n"); > ^~~~~~~~~~~~~~~~~~~~~~~~ Of course, it will fail. You need to actually have a printf_not_declared_if_0 function defined during parsing. #include #include #define MPFR_HALF_CYCLE 1 #define printf_not_declared_if_0(a) abort() int main(void) { if (MPFR_HALF_CYCLE) printf_not_declared_if_0 ("here\n"); else printf ("there\n"); return (0); } ~/work/x/bin/g++ -I/usr/local/include -o z a.cc && ./z Abort (core dumped) Changing 1 to 0 the MPFR_HALF_CYCLE define. ~/work/x/bin/g++ -I/usr/local/include -o z a.cc && ./z there Going back to my original example and g++ from master, I'm seeing % ~/work/x/bin/g++ -I/usr/local/include -E a.cc int main(void) { if (( # 9 "a.cc" 3 4=20 # 9 "a.cc" * 100 +=20 # 9 "a.cc" 3 2=20 # 9 "a.cc" >=3D 402)) printf("here\n"); else printf("there\n"); return (0); } and with clang++ % c++ -E -I/usr/local/include a.cc int main(void) { if ((4 * 100 + 2 >=3D 402)) printf("here\n"); else printf("there\n"); return (0); } Is there something that is different between your OS and FreeBSD? Or is there some fundamental difference between C and C++ that I am unaware of?=