It’s less of an issue with younger generation, but still important to be careful.
If you're at a party and no one is asking, certainly don't share it. Nothing is worse than being at a party with a guy who constantly says "By the way, I make $500k at Facebook"
If for some reason salary is important to the conversation (for example talking about crypto or investing or just money in general) then sharing it can be appropriate.
But the most important thing imo is that you read the room: if it's likely the people you're talking with make less than you, then probably don't share it, and certainly never complain about money or the price of things. If it's likely they are well off as well, then sure, complain about your mid-six-figure salary
If you’re polite about it, it not a huge issue.
However, this myth of illegality of sharing your salary information has been perpetuated by the employers to maintain an upper hand in negotiations. And it’s what keeps down the TCs in Europe, in my opinion.
I don't think that's what keeps down the TC in Europe, because what you are describing is exactly the case in the US as well.
It is 100% legal to share your comp with anyone, and it is illegal for an employer to prohibit that or fire you for it or retaliate in any other way. And yet, a giant chunk of the population lives under a myth that they can get in trouble for sharing their comp info, even when the employer doesn't insinuate so or imply that at all.
I know some small employers might (illegally) try to imply that it isn't allowed (despite it being illegal, but those bosses are either ignorant or threading a fine line with the law), but I've even met some people working at FAANG-tier companies believing that sharing comp numbers is prohibited (despite FAANG-tier companies never even subtly implying that it isn't allowed).