On 06.11.2019 18:06, Don Lewis wrote: > On 6 Nov, Branko Čibej wrote: >> On 05.11.2019 20:20, Peter Kovacs wrote: >>> I am not sure why, but if you use gcc++98 std it compiles. Maybe it >>> optimizes the code since it might be dead code. >> That would be a very, very strange way to go about things. To figure out >> something is dead code, you have to at *least* parse it first, and the >> syntax error is pretty glaring.
(Oops ... it's not, strictly speaking, a syntax error at all.) >> It's not impossible that the function is >> never called and hence previous (IMO, buggy) versions of GCC never got >> to generate the template function. > It's not just gcc, clang also is happy, at least in gnu++98 mode. I do > remember seeing this problem before, which was probably after clang > switched its default to a newer C++ standard and before I switched the > FreeBSD port to always build in gnu++98 mode. > > My suspicion is that the source is getting tokenized, but since the > method is defined in a header and will get inlined where it gets used, > it is being treated a lot like the body of a macro and the deeper > analysis of the code is getting deferred until the method gets called > somewhere. That makes sense, yes. Oooh, I could've got away with so many nasty delayed-action mines in the code if I'd only known some compilers behaved in this "interesting" way. :D -- Brane --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
