Newer gcc swallow version control keywords

Newer gcc swallow version control keywords

Nadav Har'El nyh at math.technion.ac.il
Tue Oct 18 15:14:18 IST 2011


On Tue, Oct 18, 2011, Oleg Goldshmidt wrote about "Re: Newer gcc swallow version control keywords":
> No, no, it is optimized out - Elazar tried to make a global non-static
> (non-file-scope) variable (non-constant) that *is* used (by the main()
> routine - and may be used, including modification, by anyone else.
> Apart from that the only difference between C and C++ is that in C++
> you can write a relatively simple constructor code (while dragging
> stuff like <vector< and <string> and possibly <algorithm> in) that
> will insert a reference into a global container.

I understood his intention differently. He used his "trick" not just in main,
but also in every file in his example.

Did you actually check this in C++? It seems to me like in C++, you cannot
"optimize out" (elliminate the construction of code) unused static const
variables whose type have a constructor, because this constructor can
basically do *anything*, and this code might be necessary even if the object
itself is never used.

In my opinion, if gcc does optimize out unused static const variables that
have a constructor with side effects, then it is making a mistake. I didn't
check if that actually happens. But in any case your original question was
about C, not C++.

-- 
Nadav Har'El                        |                   Tuesday, Oct 18 2011, 
nyh at math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |I'm experiencing both amnesia and deja
http://nadav.harel.org.il           |vu. I think I've forgotten this before!



More information about the Linux-il mailing list