
GCC 10.1 Released - nrgc
https://gcc.gnu.org/pipermail/gcc-announce/2020/000163.html
======
DyslexicAtheist
I love the built-in static analyzer _-fanalyzer_ option in gcc-10.

[1] [https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-
Options.h...](https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html)

~~~
glouwbug
Imagine if -fanalyze was like rusts borrow checker

~~~
simias
You Rust borrow checker requires special annotations and restrictions put on
the code to do its job. I don't think you could something like that
automatically on a C or C++ full codebase without having to manually annotate
and refactor it somewhat. There are many common (and safe) C and C++ patterns
that would be outright rejected by Rust's borrow checker, for instance
initializing a structure or array partially if you're sure that nobody is
going to use the initialized portion. Or having multiple mutable
pointers/reference to the same object.

You could do something like that at runtime though, but then you have
Valgrind, basically.

~~~
pkolaczk
> Rust borrow checker requires special annotations and restrictions put on the
> code to do its job.

This is a good thing, because it makes lifetimes and ownership explicit and
visible in the code. It serves the similar purpose as type annotations in
function signatures.

> Or having multiple mutable pointers/reference to the same object

Sure you can have that with `unsafe`. And this is a good thing, because
multiple mutable pointers to the same object is at best bad coding practice
that leads to unsafe code, and you should avoid that in any language,
including the ones with GC. Working with codebases where there are multiple
distant things mutating shared stuff is a terrible experience.

If a C/C++ version of "borrow checker" could mark such (anti)patterns at least
as warnings, that would bring a lot of value.

~~~
verdagon
Can you explain why multiple mutable pointers is bad practice?

I understand the benefits and the risks of them, and understand how Rust
prevents both, but I dont yet understand why it's bad practice, and am
interested to learn why.

~~~
cormacrelf
The one that affects you as a programmer most is Iterator invalidation. Iter
borrows from the vector, you mutate the vector, iter blows up. Simple really.
But a lot of code is like this. Borrow from hashmap, insert into hashmap, the
slot gets moved around and your pointer is now invalid. That’s just vectors
and hashmaps; imagine the possibilities in a much more complex data structure.

There are compiler optimisations you can do if compiler knows about aliasing,
but that’s not so much a software authorship problem. There are some curly
problems with passing aliased mutable pointers to a function written for non-
aliased inputs, like memcpy and I imagine quite a lot of other code.

But common to all of these things is that it’s pretty hard to figure out if
the programmer is the one who has to track the aliasing. In hashmap pointer
invalidation, your code might work perfectly for years until some input comes
along and finally triggers a shift or a reallocation at the exact right time.
(I know this — I recently had to write a lot of C and these are the kinds of
issues you get even after you implement some of Rust’s std APIs in C.)

~~~
verdagon
Is this still bad practice if the container can detect when this happens, like
Java's? Not saying that it always has to throw like Java, I could imagine
implementing a weak iter which we'd check before each operation.

------
MauranKilom
> Extended characters in identifiers may now be specified directly in the
> input encoding (UTF-8, by default), in addition to the UCN syntax (\uNNNN or
> \UNNNNNNNN) that is already supported:
    
    
        static const int π = 3;
        int get_naïve_pi() {
          return π;
        }
    

Lovely!

~~~
q92z8oeif
i don't know if you are being ironic or not, but the non-english speaking
world will love it.

~~~
alufers
As a non-English programmer who has seen a lot of code not written using
English please, god, NO. The mixture of English and other languages
identifiers in the external libraries makes me cry.

~~~
wiz21c
Yep, writing non english keywords in C++ is like having prolog code inside c++
:-)

(but as a non english person, I find it _very_ helpful to be able to have
unicode in strings)

------
greendave
> Several C++20 features have been implemented: > P0912R5, Coroutines
> (requires -fcoroutines)

Nice to see a bunch of C++20 features making it in. Coroutines seems like a
big one!

------
vmchale
Lovely! Time to see my code go even faster, for free :)

------
FullyFunctional
memory.c: In function ‘mk_entry’: memory.c:116:12: internal compiler error: in
saved_diagnostic, at analyzer/diagnostic-manager.cc:84 116 | return (struct
entry) {safe_calloc(end - start, 1), start, end}; | ^ Please submit a full bug
report,

Goes to look at README.Bugs. Holy cow, I don't have time to to check all those
places to see if it has been reported already.

~~~
canarypilot
The GCC community is normally very good (if blunt) at picking up duplicate
bugs and linking them to the right place.
[https://gcc.gnu.org/bugzilla/](https://gcc.gnu.org/bugzilla/) Is all you
need. Just don’t feel bad if your bug is closed!

~~~
FullyFunctional
Thanks, it was fixed already :)

------
wiz21c
(side note for RMS, I still have a "RUNGCC" sticker on my car (it's been 5
years !!!))

------
liquidify
wish gcc 10 was built into ubuntu 20.04

~~~
loeg
If you want the newest version of software, Ubuntu does not cater to that.

~~~
e12e
Well, you might want to run a newer/non-lts release via lxd/lxc. It's probably
a much better idea than pulling in willy-nilly ppa's.

~~~
purerandomness
But at this point, why not simply run Arch Linux?

~~~
simion314
You might want LTS and upgrade some packages when needed/forced and not play
the "update" lottery. New updates not only bring you cool new feature and
fixes , they bring new bugs and sometimes features are removed or GUIs are
moved around. At least with my LTS I worked around for existing bugs ,
upgraded from PPA the things I needed to, browsers are latest versions and my
IDE is auto-updating too.

------
super_mario
It doesn't seem to be available on the main site or any of the mirrors I
tried.

~~~
chrisseaton
> It doesn't seem to be available on the main site

Surely it's available from here at the very least?

[https://gcc.gnu.org/git.html](https://gcc.gnu.org/git.html)

> or any of the mirrors I tried

Seems to be to me?

ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-10.1.0/

