(which shows that big-endian Linux is still supported).
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas Koenig) wrote:
(which shows that big-endian Linux is still supported).
Which PowerPC Linux was that? Not many distributions have big-endian.
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian
platforms, because it made some kinds of bugs much more obvious.
However,
it wasn't enough value to make it worth buying hardware for Solaris on
SPARC or AIX on POWER once there were no customers for them. If there's a big-endian PowerPC Linux with a future, that would be interesting.
John Dallman <jgd@cix.co.uk> schrieb:
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas
Koenig) wrote:
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian
platforms, because it made some kinds of bugs much more obvious.
Like passing a char to an int...
On 06/09/2026 11:20, Thomas Koenig wrote:
John Dallman <jgd@cix.co.uk> schrieb:
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas >>> Koenig) wrote:
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian
platforms, because it made some kinds of bugs much more obvious.
Like passing a char to an int...
Could you expand on that? I am curious about what you mean here.
David Brown <david.brown@hesbynett.no> schrieb:
On 06/09/2026 11:20, Thomas Koenig wrote:
John Dallman <jgd@cix.co.uk> schrieb:
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas >>>> Koenig) wrote:
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian
platforms, because it made some kinds of bugs much more obvious.
Like passing a char to an int...
Could you expand on that? I am curious about what you mean here.
I was being rather imprecise, thinking of Fortran more than of C.
What I meant was something like
#include <stdio.h>
void printit(void *p)
{
char *c = p;
printf ("Value is: %d\n", *c);
}
int main()
{
int i = 42;
printit (&i);
return 0;
}
which yields "Value is: 0" on a big-endian machine.
On 06/09/2026 14:17, Thomas Koenig wrote:
David Brown <david.brown@hesbynett.no> schrieb:
On 06/09/2026 11:20, Thomas Koenig wrote:
John Dallman <jgd@cix.co.uk> schrieb:
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas >>>>> Koenig) wrote:
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian
platforms, because it made some kinds of bugs much more obvious.
Like passing a char to an int...
Could you expand on that? I am curious about what you mean here.
I was being rather imprecise, thinking of Fortran more than of C.
What I meant was something like
#include <stdio.h>
void printit(void *p)
{
char *c = p;
printf ("Value is: %d\n", *c);
}
int main()
{
int i = 42;
printit (&i);
return 0;
}
which yields "Value is: 0" on a big-endian machine.
Okay, but that is well-defined behaviour in C (with a smattering of implementation-defined behaviour for the signedness of plain char and
the sizes involved - the machine could have the same size for "char" and "int", and thus print "42"). You are using a character pointer to
access the first byte of the representation of "i" in memory, and that
is of course the MSB in a big-endian system. It is one of relatively
few ways you can distinguish the endianness.
I know very little of Fortran - is it significantly different from C
here? (Again, this is just curiosity.)
David Brown <david.brown@hesbynett.no> schrieb:
On 06/09/2026 14:17, Thomas Koenig wrote:
David Brown <david.brown@hesbynett.no> schrieb:
On 06/09/2026 11:20, Thomas Koenig wrote:
John Dallman <jgd@cix.co.uk> schrieb:
In article <10vpuu9$3ttut$1@dont-email.me>, tkoenig@netcologne.de (Thomas
Koenig) wrote:
But if the software you are targeting is primarily written on,
and for, little-endian systems like x86
My employer found some value in building and testing on big-endian >>>>>> platforms, because it made some kinds of bugs much more obvious.
Like passing a char to an int...
Could you expand on that? I am curious about what you mean here.
I was being rather imprecise, thinking of Fortran more than of C.
What I meant was something like
#include <stdio.h>
void printit(void *p)
{
char *c = p;
printf ("Value is: %d\n", *c);
}
int main()
{
int i = 42;
printit (&i);
return 0;
}
which yields "Value is: 0" on a big-endian machine.
Okay, but that is well-defined behaviour in C (with a smattering of
implementation-defined behaviour for the signedness of plain char and
the sizes involved - the machine could have the same size for "char" and
"int", and thus print "42"). You are using a character pointer to
access the first byte of the representation of "i" in memory, and that
is of course the MSB in a big-endian system. It is one of relatively
few ways you can distinguish the endianness.
Jep.
However, if code depends on a particular ordering, for example if
this needs to print 42, the code is buggy on big-endian systems.
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
Another thing that is also access to subwords via unions.
I know very little of Fortran - is it significantly different from C
here? (Again, this is just curiosity.)
Fortran argument passing is not specified by the standard. In
FORTRAN 77 days, it was usually implemented via pointers to each
argument. If you had
INTEGER*4 I
I = 42
CALL FOO(I)
...
SUBROUTINE FOO(I)
INTEGER*2 I
PRINT *,I
you would get the same effect, but the program would be illegal
from the start.
This is the kind of error that little-endian will hide, and
big-endian will not.
Not sure what the future is... hard to say who is still actually
running it.
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
Lying to your compiler is rarely a good idea! But this one is easy -
"int" and "long int" are not compatible, so it is /never/ appropriate to
mix them - regardless of size.
Another thing that is also access to subwords via unions.
That will also be endian-dependent, because it is reliant on re-interpretation of the underlying representation. (It can also be a
risk in that while type-punning via unions is defined behaviour in C, it
is UB in C++.)
Fortran argument passing is not specified by the standard. In
FORTRAN 77 days, it was usually implemented via pointers to each
argument.
David Brown <david.brown@hesbynett.no> posted:
---------------
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
What about ILP32 programming environments ??
Lying to your compiler is rarely a good idea! But this one is easy -
"int" and "long int" are not compatible, so it is /never/ appropriate to
mix them - regardless of size.
What about ILP32 programming environments ??
Another thing that is also access to subwords via unions.
That will also be endian-dependent, because it is reliant on
re-interpretation of the underlying representation. (It can also be a
risk in that while type-punning via unions is defined behaviour in C, it
is UB in C++.)
When done it must be done where the struct declaration has #ifdef ENDIAN
so the struct is properly defined in both endian-nesses.
for the gcc compile farm.
According to Thomas Koenig <tkoenig@netcologne.de>:
https://portal.cfarm.net/machines/list/ has a list of machines
for the gcc compile farm.
I see a bunch of s390 machines on that last. IBM actively supports
linux on zSeries and as long as they do that, there's going to be
some bigendian linux systems.
On 07/09/2026 01:51, MitchAlsup wrote:--------------
Code that lies to the compiler - saying that you have a pointer to an
"int", when in fact the object pointed to is a "long int" - might work.
But it is UB, and compilers can (and do) optimise on the assumption that
you are a responsible programmer who knows the language and follows the rules.
int bar(int * pi, long int * pl) {
static_assert(sizeof(int) == sizeof(long int));
*pi = 1;
*pl = 2;
return *pi;
}
Godbolt 32-bit ARM gcc 16, -O2 -Wall -Wextra -Wpedantic -march=armv8-a :
bar:
mov r2, r0
mov r3, #2
mov r0, #1
str r0, [r2]
str r3, [r1]
bx lr
David Brown <david.brown@hesbynett.no> posted:
On 07/09/2026 01:51, MitchAlsup wrote:--------------
Code that lies to the compiler - saying that you have a pointer to anSeems unnecessarily long::
"int", when in fact the object pointed to is a "long int" - might work.
But it is UB, and compilers can (and do) optimise on the assumption that
you are a responsible programmer who knows the language and follows the
rules.
int bar(int * pi, long int * pl) {
static_assert(sizeof(int) == sizeof(long int));
*pi = 1;
*pl = 2;
return *pi;
}
Godbolt 32-bit ARM gcc 16, -O2 -Wall -Wextra -Wpedantic -march=armv8-a :
bar:
mov r2, r0
mov r3, #2
mov r0, #1
str r0, [r2]
str r3, [r1]
bx lr
bar:
STW #1,[R1]
STW #2,[R2]
MOV R1,#1
RET
On 07/09/2026 20:22, MitchAlsup wrote:
David Brown <david.brown@hesbynett.no> posted:
On 07/09/2026 01:51, MitchAlsup wrote:--------------
Code that lies to the compiler - saying that you have a pointer to anSeems unnecessarily long::
"int", when in fact the object pointed to is a "long int" - might work.
But it is UB, and compilers can (and do) optimise on the assumption that >> you are a responsible programmer who knows the language and follows the
rules.
int bar(int * pi, long int * pl) {
static_assert(sizeof(int) == sizeof(long int));
*pi = 1;
*pl = 2;
return *pi;
}
Godbolt 32-bit ARM gcc 16, -O2 -Wall -Wextra -Wpedantic -march=armv8-a : >>
bar:
mov r2, r0
mov r3, #2
mov r0, #1
str r0, [r2]
str r3, [r1]
bx lr
bar:
STW #1,[R1]
STW #2,[R2]
MOV R1,#1
RET
ARM does not have instructions to store immediates like that. It's a load/store architecture - you need to put the immediate values into registers, then store them.
David Brown <david.brown@hesbynett.no> posted:
On 07/09/2026 20:22, MitchAlsup wrote:
David Brown <david.brown@hesbynett.no> posted:
On 07/09/2026 01:51, MitchAlsup wrote:--------------
Code that lies to the compiler - saying that you have a pointer to anSeems unnecessarily long::
"int", when in fact the object pointed to is a "long int" - might work. >>>> But it is UB, and compilers can (and do) optimise on the assumption that >>>> you are a responsible programmer who knows the language and follows the >>>> rules.
int bar(int * pi, long int * pl) {
static_assert(sizeof(int) == sizeof(long int));
*pi = 1;
*pl = 2;
return *pi;
}
Godbolt 32-bit ARM gcc 16, -O2 -Wall -Wextra -Wpedantic -march=armv8-a : >>>>
bar:
mov r2, r0
mov r3, #2
mov r0, #1
str r0, [r2]
str r3, [r1]
bx lr
bar:
STW #1,[R1]
STW #2,[R2]
MOV R1,#1
RET
ARM does not have instructions to store immediates like that. It's a
load/store architecture - you need to put the immediate values into
registers, then store them.
My 66000 is a LD store architecture, too, but there are encodings that
allow the Rd specifier to be used as a small immediate.
John Levine <johnl@taugh.com> schrieb:
According to Thomas Koenig <tkoenig@netcologne.de>: >>>https://portal.cfarm.net/machines/list/ has a list of machines
for the gcc compile farm.
I see a bunch of s390 machines on that last. IBM actively supports
linux on zSeries and as long as they do that, there's going to be
some bigendian linux systems.
Another interesting tidbit in that respect: gcc 17 will drop
support for 31-bit s390.
David Brown <david.brown@hesbynett.no> posted:
---------------
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
What about ILP32 programming environments ??
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
David Brown <david.brown@hesbynett.no> posted:
---------------
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
What about ILP32 programming environments ??
Long obsolete and pretty much useless in these modern times.
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
David Brown <david.brown@hesbynett.no> posted:
---------------
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
What about ILP32 programming environments ??
Long obsolete and pretty much useless in these modern times.
Scott Lurndal <scott@slp53.sl.home> schrieb:
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
David Brown <david.brown@hesbynett.no> posted:
---------------
And if you make the mismatch int*/long* instead, you will get
undefined behavior that is also difficult to catch, if you lie
to your compiler.
What about ILP32 programming environments ??
Long obsolete and pretty much useless in these modern times.
On embedded systems, for example 32-bit ARM?
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 74 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 121:08:59 |
| Calls: | 1,194 |
| Files: | 1,352 |
| Messages: | 290,208 |