News for hackers. Stuff that matters.
Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @07:46AM (#40284408)
It's worth noting that this release breaks a lot of older code, see: https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3...

It enables a few -Werror flags by default, refusing to compile code with probable undefined behavior. Unfortunately, a lot of older code subtly raises these warnings (now hard errors), even in cases where it's "fine" (due to valid platform assumptions).

Re:GCC 14.1 Release by rwmj on Tuesday May 07, 2024 @07:59AM (#40284484)
This is true but by now distros have fixed most of the breakage and sent the changes back upstream (certainly this is true for Fedora).
Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @08:06AM (#40284528)
Well, yeah, for maintained upstreams. I sometimes need to build older versions of software and simply use unmaintained software, for which these changes are a bit of a pain, along with -fno-common before it.
Re:GCC 14.1 Release by mikepurvis on Tuesday May 07, 2024 @09:18AM (#40285092)
At a certain point, it's probably easier to build and run the unmaintained software in a container running an OS of corresponding vintage. Obviously that has security ramifications, but hopefully this software isn't facing the internet and being in a container at least means you're on a modern kernel and can isolate things at a port and filesystem level.
Re:GCC 14.1 Release by withzombies on Tuesday May 07, 2024 @09:52AM (#40285454)
Debian is super good for this. Most of their apt mirrors are still up and running, so you can easily download and build software from 2002 if you use the appropriate Debian release to do it.

I usually do this first to make sure the software builds and works, then I try to figure out how to get it working on a newer OS.

Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @05:21PM (#40291650)
You're right, but it's also significantly more inconvenient.
Re:GCC 14.1 Release by cozzyd on Tuesday May 07, 2024 @10:37AM (#40286027)
it would be nice if they provided a gcc-ancient-compat or something though it's easy enough to create an alias with the correct flags.
Re:GCC 14.1 Release by Phyx on Tuesday May 07, 2024 @11:50AM (#40287249)
-std=gnu98 works. ie explicitly telling it your code is not modern C.
Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @05:20PM (#40291645)
The new flags apply regardless of -std value, as does -fno-common
Re:GCC 14.1 Release by Phyx on Tuesday May 07, 2024 @09:14PM (#40293371)
Uhh no they don't, and it's explicitly documented under https://gcc.gnu.org/gcc-14/porting_to.html in "Turning errors back into warnings".

Futher more every warning Explains why the std value affects them.

Re:GCC 14.1 Release by dooglius on Tuesday May 07, 2024 @09:14AM (#40285052)
Very easily worked around with -Wno
Re:GCC 14.1 Release by sqeaky on Tuesday May 07, 2024 @05:01PM (#40291431)
I might be wrong, but it is my understanding that a lot of these warnings deal with undefined or implementation defined behavior and that behavior is changing this release. If that understanding is close, for even some of these, then just suppressing the warnings means the software will behave differently.
Re:GCC 14.1 Release by dooglius on Tuesday May 07, 2024 @07:10PM (#40292576)
My understanding is that these were all existing warnings that were off by default (you needed to pass -Wall to see) that are now displayed by default; I don't see any indication in the patch thread that there were corresponding behavior changes.
Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @05:25PM (#40291681)
Nah, you can override the flags and still will remain working, but you have to be aware of it and figure out how to change the flags of a project properly.
Re:GCC 14.1 Release by emidln on Tuesday May 07, 2024 @09:19AM (#40285109)
It's great seeing progress made here. C/C++ will never be truly safe languages, but every little bit the compiler can help with is appreciated, esp by those maintaining established codebases.
Re:GCC 14.1 Release by ho_schi on Tuesday May 07, 2024 @10:16AM (#40285733)
CPP2/cppfront:

https://github.com/hsutter/cppfront

I hope we see this in C++26 as optional mode i.e. #safe and #unsafe and same for #impdef or so.

Re:GCC 14.1 Release by pjmlp on Tuesday May 07, 2024 @11:07AM (#40286544)
It is only yet another wannabe C++ replacement, regardless how it is sold as not being one.
Re:GCC 14.1 Release by ho_schi on Tuesday May 07, 2024 @03:39PM (#40290567)
A wannabe replacement by…Herb Sutter. I dare to differ.
Re:GCC 14.1 Release by pjmlp on Tuesday May 07, 2024 @03:59PM (#40290798)
Which is exactly why he pretends to not be a wannabe replacement, as it is politically incorrect to have the chair of ISO C++ to also propose a C++ replacement.

CFront wasn't C, nor Objective-C was C, even though both originally started as macro preprocessors targeting C code generation, and were like Typescript for C.

They became their own thing, after enough user based was won, and nowadays all major C compilers and standard libraries are written in C++, not C.

Re:GCC 14.1 Release by jcranmer on Tuesday May 07, 2024 @10:11AM (#40285670)
Looking at those flags, several of them are erroring about things that have been deprecated since before I was born. If you're going to complain that it's breaking old code, I have to ask why this code is simultaneously important enough to you to use a modern compiler with modern flags to build it and not important enough to bother changing for 30 years.
Re:GCC 14.1 Release by hulitu on Tuesday May 07, 2024 @04:04PM (#40290849)
> things that have been deprecated since before I was born.

You must be very young.

Breaking compilation is not a sign of maturity. See Rust for details.

Re:GCC 14.1 Release by gizmo686 on Tuesday May 07, 2024 @04:16PM (#40290960)
Rust is 9 years old. By programming language standards, it is the new kid around the block.

C is over 50 years old.

Python is 30.

Haskell 35

Java 30

Re:GCC 14.1 Release by mid-kid on Tuesday May 07, 2024 @05:16PM (#40291590)
Plenty of software broke as a result of these flags, gentoo has a tracker here: https://bugs.gentoo.org/showdependencytree.cgi?id=870412&hid...

As per my own experiences so far, we maintain an older version of GCC for matching GBA decompilation projects, which exhibits compilation errors now.

Re:GCC 14.1 Release by wiseowise on Tuesday May 07, 2024 @10:35AM (#40285991)
Good. Long overdue.
Re:GCC 14.1 Release by PKop on Tuesday May 07, 2024 @10:40AM (#40286072)
>enables a few -Werror flags by default

Presumably they can then be disabled when needed yes? Sounds like a better default.

Re:GCC 14.1 Release by fl0ki on Tuesday May 07, 2024 @12:34PM (#40287951)
It says a lot that this document has to include things like this:

> Only cast if confident it's correct, otherwise investigate more. Casts will silence real problems if incorrectly used.

> Do not assume it is supposed to be an int.

> Do not simply cast to the "other side" of the error. Casts will silence warnings/errors, but that does not mean the cast is correct.

Besides the increasingly well-known footguns of old C code, we're always going to have problems if there isn't an inherent safety culture among the people maintaining open source projects, whether as upstream or a distributor.