This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

s390x (64 bit) macro expansion WCOREDUMP


hi,

I have hit an issue with gcc 4.8.5 on s390x (big endian machine) while
expanding macros (e.g. WCOREDUMP).
I unsure why this is happening only when the first macro parameter is of
type long.

Take the sample program:

```
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
  if (WCOREDUMP((long)128L)) { printf("WCOREDUMP not zero\n");
  } else { printf("WCOREDUMP !zero!\n"); }
  return 0;
}
```

the macro in the if condition is expaned to:

```
if ((((__extension__ (((union { __typeof((long)128L) __in; int __i; }) {
.__in = ((long)128L) }).__i))) ...
```

Since this is a big endian machine the field access __i will always
return 0.

I had a look at the macro and how it is defined:
gcc/gcc/system.h:#define WCOREDUMP(S) ((S) & WCOREFLG)

What is the reason for this extra union type and the assumption that the
parameter must be of type int?

Cheers,
Richard

PS.: Here is some of my configuration:

$ uname -a
Linux pypy.novalocal 3.10.0-327.4.4.el7.s390x #1 SMP Thu Dec 17 15:52:10
EST 2015 s390x s390x s390x GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/s390x-redhat-linux/4.8.5/lto-wrapper
Target: s390x-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,go,lto
--enable-plugin --enable-initfini-array --disable-libgcj
--with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-s390x-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-s390x-redhat-linux/cloog-install
--enable-gnu-indirect-function --with-long-double-128 --with-arch=z196
--with-tune=zEC12 --enable-decimal-float --build=s390x-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)

# command I used to obtained the preprocessed source:
$ gcc -v -save-temps ~/test.c

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]