Bug 101211 - [12 regression] 17_intro/names.cc fails
Summary: [12 regression] 17_intro/names.cc fails
Status: RESOLVED DUPLICATE of bug 97088
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-25 14:22 UTC by Christophe Lyon
Modified: 2021-06-25 17:09 UTC (History)
2 users (show)

See Also:
Host:
Target: arm aarch64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-06-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Lyon 2021-06-25 14:22:22 UTC
I've noticed that 17_intro/names.cc fails to compile on arm/aarch64 (and others according to gcc-testresults):
FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/sysroot-arm-none-linux-gnueabi/usr/include/sys/ucontext.h:89: error: expected unqualified-id before ':' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/sysroot-arm-none-linux-gnueabi/usr/include/sys/ucontext.h:89: error: expected ')' before ':' token


This appeared between r12-1737 and r12-1744
Comment 1 Jonathan Wakely 2021-06-25 15:24:38 UTC
Presumably r12-1742

Is __lockable used as an identifier in that header?

Maybe I need to revert the change to the test. But then we won't have any verification that we don't reintroduce the name __lockable, which breaks newlib targets.
Comment 2 Jonathan Wakely 2021-06-25 15:28:25 UTC
Oh, is it this?

    unsigned int j:1;
Comment 3 Jonathan Wakely 2021-06-25 15:34:16 UTC
Ah, I bet it started to fail because I added this to the test:

{ dg-add-options no_pch }

So this should fix it for arm:

--- a/libstdc++-v3/testsuite/17_intro/names.cc
+++ b/libstdc++-v3/testsuite/17_intro/names.cc
@@ -208,6 +208,11 @@
 #undef r
 #endif
 
+#if defined (__linux__) && defined (__arm__)
+// <sys/ucontext.h> defines fpregset_t::fpregs::j
+#undef j
+#endif
+
 #if defined (__linux__) && defined (__powerpc__)
 // <asm/types.h> defines __vector128::u
 #undef u


What is the exact error for aarch64?
Comment 4 Christophe Lyon 2021-06-25 15:37:37 UTC
It works for aarch64-linux-gnu, but fails for aarch64-elf (with newlib):
FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:194: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:195: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:196: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:197: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:198: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:199: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:200: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:201: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/time.h:110: error: expected unqualified-id before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/time.h:110: error: expected ')' before ';' token
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/inttypes.h:323: error: expected ')' before ';' token
Comment 5 Jonathan Wakely 2021-06-25 15:59:38 UTC
(In reply to Christophe Lyon from comment #4)
> It works for aarch64-linux-gnu, but fails for aarch64-elf (with newlib):
> FAIL: 17_intro/names.cc (test for excess errors)
> Excess errors:
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:194:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:195:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:196:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:197:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:198:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:199:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:200:
> error: expected ')' before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:201:
> error: expected ')' before ';' token

I think that's due to bugs in newlib's <math.h> on these lines:


extern int __isinff (float x);
extern int __isinfd (double x);
extern int __isnanf (float x);
extern int __isnand (double x);
extern int __fpclassifyf (float x);
extern int __fpclassifyd (double x);
extern int __signbitf (float x);
extern int __signbitd (double x);

Those should use __x not x.

> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/time.h:110:
> error: expected unqualified-id before ';' token
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/time.h:110:
> error: expected ')' before ';' token

Non-reserved names in this newlib type:

typedef struct __tzrule_struct
{
  char ch;
  int m;
  int n;
  int d;
  int s;
  time_t change;
  long offset; /* Match type of _timezone. */
} __tzrule_type;

I'll have to adjust the test for that.


> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/inttypes.h:
> 323: error: expected ')' before ';' token

This is a newlib bug:
extern intmax_t  imaxabs(intmax_t j);

It should be using __j here, and similarly for the next line:
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);
Comment 6 Jonathan Wakely 2021-06-25 17:08:24 UTC
(In reply to Jonathan Wakely from comment #5)
> (In reply to Christophe Lyon from comment #4)
> > It works for aarch64-linux-gnu, but fails for aarch64-elf (with newlib):
> > FAIL: 17_intro/names.cc (test for excess errors)
> > Excess errors:
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:194:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:195:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:196:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:197:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:198:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:199:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:200:
> > error: expected ')' before ';' token
> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/math.h:201:
> > error: expected ')' before ';' token
> 
> I think that's due to bugs in newlib's <math.h> on these lines:
> 
> 
> extern int __isinff (float x);
> extern int __isinfd (double x);
> extern int __isnanf (float x);
> extern int __isnand (double x);
> extern int __fpclassifyf (float x);
> extern int __fpclassifyd (double x);
> extern int __signbitf (float x);
> extern int __signbitd (double x);
> 
> Those should use __x not x.

Which you already fixed:

commit 4c49accf8997da21be19be0396b2a88f33b9f949
Author: Christophe Lyon
Date:   Mon Sep 21 15:22:30 2020 +0000

    libc/include/math.h: Remove parameter name
    
    As discussed in GCC bug 97088
    (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in
    prototypes of library functions should use reserved names, or no name
    at all.


> > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/include/inttypes.h:
> > 323: error: expected ')' before ';' token
> 
> This is a newlib bug:
> extern intmax_t  imaxabs(intmax_t j);
> 
> It should be using __j here, and similarly for the next line:
> extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer);

That was fixed in newlib a few months ago as well:

commit 615cf4bdce0de86e57bdc27e008a35dd713e483f
Author: Torbjörn SVENSSON
Date:   Thu Oct 1 12:44:43 2020 +0200

    libc/include/inttypes.h: Remove parameter name
    
    As discussed in GCC bug 97088
    (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in
    prototypes of library functions should use reserved names, or no name
    at all.
Comment 7 Jonathan Wakely 2021-06-25 17:09:16 UTC
dup, but it now happens without --disable-libstdcxx-pch because the test disables pch itself.

*** This bug has been marked as a duplicate of bug 97088 ***