* Doc question: is "templatized" a word? @ 2017-02-11 4:11 Sandra Loosemore 2017-02-11 8:48 ` Gerald Pfeifer 0 siblings, 1 reply; 8+ messages in thread From: Sandra Loosemore @ 2017-02-11 4:11 UTC (permalink / raw) To: gcc The documentation for -Wno-non-template-friend refers to "non-templatized friend functions" and "templatized functions". I don't see the term "templatized" used anywhere in the C++ standard. This paragraph also uses "nontemplate function", which I assume refers to the same thing the C++ standard spells "non-template function". So does "non-templatized function" also mean "non-template function"? Or does it have some other meaning? -Sandra the confused ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-11 4:11 Doc question: is "templatized" a word? Sandra Loosemore @ 2017-02-11 8:48 ` Gerald Pfeifer 2017-02-11 13:21 ` Jonathan Wakely 0 siblings, 1 reply; 8+ messages in thread From: Gerald Pfeifer @ 2017-02-11 8:48 UTC (permalink / raw) To: Sandra Loosemore; +Cc: gcc On Fri, 10 Feb 2017, Sandra Loosemore wrote: > The documentation for -Wno-non-template-friend refers to "non-templatized > friend functions" and "templatized functions". I don't see the term > "templatized" used anywhere in the C++ standard. This paragraph also uses > "nontemplate function", which I assume refers to the same thing the C++ > standard spells "non-template function". So does "non-templatized function" > also mean "non-template function"? Or does it have some other meaning? I would avoid "templatized" and believe "non-template function" is more appropriate in your example. Gerald ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-11 8:48 ` Gerald Pfeifer @ 2017-02-11 13:21 ` Jonathan Wakely 2017-02-11 20:36 ` Sandra Loosemore 0 siblings, 1 reply; 8+ messages in thread From: Jonathan Wakely @ 2017-02-11 13:21 UTC (permalink / raw) To: Gerald Pfeifer; +Cc: Sandra Loosemore, gcc On 11 February 2017 at 08:48, Gerald Pfeifer wrote: > On Fri, 10 Feb 2017, Sandra Loosemore wrote: >> The documentation for -Wno-non-template-friend refers to "non-templatized >> friend functions" and "templatized functions". I don't see the term >> "templatized" used anywhere in the C++ standard. This paragraph also uses >> "nontemplate function", which I assume refers to the same thing the C++ >> standard spells "non-template function". So does "non-templatized function" >> also mean "non-template function"? Or does it have some other meaning? > > I would avoid "templatized" and believe "non-template function" is > more appropriate in your example. Yes, s/non-templatized/non-template/ s/nontemplate/non-template/ s/templatized function/function template/ But I wonder if that warning is even useful nowadays. The example of "friend foo(int);" is bogus and is correctly rejected: fr.cc:2:17: error: ISO C++ forbids declaration of ‘foo’ with no type [-fpermissive] friend foo(int); ^ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-11 13:21 ` Jonathan Wakely @ 2017-02-11 20:36 ` Sandra Loosemore 2017-02-11 21:20 ` Jonathan Wakely 0 siblings, 1 reply; 8+ messages in thread From: Sandra Loosemore @ 2017-02-11 20:36 UTC (permalink / raw) To: Jonathan Wakely, Gerald Pfeifer; +Cc: gcc On 02/11/2017 06:21 AM, Jonathan Wakely wrote: > On 11 February 2017 at 08:48, Gerald Pfeifer wrote: >> On Fri, 10 Feb 2017, Sandra Loosemore wrote: >>> The documentation for -Wno-non-template-friend refers to "non-templatized >>> friend functions" and "templatized functions". I don't see the term >>> "templatized" used anywhere in the C++ standard. This paragraph also uses >>> "nontemplate function", which I assume refers to the same thing the C++ >>> standard spells "non-template function". So does "non-templatized function" >>> also mean "non-template function"? Or does it have some other meaning? >> >> I would avoid "templatized" and believe "non-template function" is >> more appropriate in your example. > > Yes, > > s/non-templatized/non-template/ > s/nontemplate/non-template/ > s/templatized function/function template/ > > But I wonder if that warning is even useful nowadays. The example of > "friend foo(int);" is bogus and is correctly rejected: > > fr.cc:2:17: error: ISO C++ forbids declaration of âfooâ with no type > [-fpermissive] > friend foo(int); > ^ I hadn't actually gotten that far :-) but it looks like that's an implicit-int error unrelated to the actual purpose of this option. This ended up on my todo list firstly because "templatized" didn't spell-check, and secondly because the "new compiler behavior" documented in connection with this option has existed at least since 1998 and can hardly be considered "new" any more. Also I think the reference to section 14.5.3 of the C++ standard is bit-rotten (it's 14.5.4 in the c++0x draft I have handy). I'll leave it up to the C++ experts to decide whether the option should just be removed and the warning replaced with a hard error controlled by some other flag. Otherwise the docs for this option need to be rewritten to explain what it does without reference to ancient changes in G++ from before templates were fully implemented. I can take a stab at that if nobody else offers up some alternative text first. -Sandra ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-11 20:36 ` Sandra Loosemore @ 2017-02-11 21:20 ` Jonathan Wakely 2017-02-15 15:53 ` Jason Merrill 0 siblings, 1 reply; 8+ messages in thread From: Jonathan Wakely @ 2017-02-11 21:20 UTC (permalink / raw) To: Sandra Loosemore, Jason Merrill; +Cc: Gerald Pfeifer, gcc On 11 February 2017 at 20:36, Sandra Loosemore wrote: > On 02/11/2017 06:21 AM, Jonathan Wakely wrote: >> >> On 11 February 2017 at 08:48, Gerald Pfeifer wrote: >>> >>> On Fri, 10 Feb 2017, Sandra Loosemore wrote: >>>> >>>> The documentation for -Wno-non-template-friend refers to >>>> "non-templatized >>>> friend functions" and "templatized functions". I don't see the term >>>> "templatized" used anywhere in the C++ standard. This paragraph also >>>> uses >>>> "nontemplate function", which I assume refers to the same thing the C++ >>>> standard spells "non-template function". So does "non-templatized >>>> function" >>>> also mean "non-template function"? Or does it have some other meaning? >>> >>> >>> I would avoid "templatized" and believe "non-template function" is >>> more appropriate in your example. >> >> >> Yes, >> >> s/non-templatized/non-template/ >> s/nontemplate/non-template/ >> s/templatized function/function template/ >> >> But I wonder if that warning is even useful nowadays. The example of >> "friend foo(int);" is bogus and is correctly rejected: >> >> fr.cc:2:17: error: ISO C++ forbids declaration of ‘foo’ with no type >> [-fpermissive] >> friend foo(int); >> ^ > > > I hadn't actually gotten that far :-) but it looks like that's an > implicit-int error unrelated to the actual purpose of this option. > > This ended up on my todo list firstly because "templatized" didn't > spell-check, and secondly because the "new compiler behavior" documented in > connection with this option has existed at least since 1998 and can hardly > be considered "new" any more. Also I think the reference to section 14.5.3 > of the C++ standard is bit-rotten (it's 14.5.4 in the c++0x draft I have > handy). > > I'll leave it up to the C++ experts to decide whether the option should just > be removed and the warning replaced with a hard error controlled by some > other flag. It definitely shouldn't be turned into a hard error, the warning complains about valid code, such as: template<typename T> struct A { friend int foo(T); }; int main() { A<int> a; } I think it warns because the meaning of that code changed, a *long* time ago, so it's saying "if you wrote this code in the 1990s it might do something different to what you expect." I'm not sure how useful that warning is now, although EDG warns for it too (with a fix-it hint that I think is bogus): "fr.cc", line 2: warning: "int foo(T)" declares a non-template function -- add <> to refer to a template instance friend int foo(T); ^ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-11 21:20 ` Jonathan Wakely @ 2017-02-15 15:53 ` Jason Merrill 2017-02-15 18:57 ` Jonathan Wakely 0 siblings, 1 reply; 8+ messages in thread From: Jason Merrill @ 2017-02-15 15:53 UTC (permalink / raw) To: Jonathan Wakely; +Cc: Sandra Loosemore, Gerald Pfeifer, gcc On Sat, Feb 11, 2017 at 4:19 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote: > On 11 February 2017 at 20:36, Sandra Loosemore wrote: >> On 02/11/2017 06:21 AM, Jonathan Wakely wrote: >>> >>> On 11 February 2017 at 08:48, Gerald Pfeifer wrote: >>>> >>>> On Fri, 10 Feb 2017, Sandra Loosemore wrote: >>>>> >>>>> The documentation for -Wno-non-template-friend refers to >>>>> "non-templatized >>>>> friend functions" and "templatized functions". I don't see the term >>>>> "templatized" used anywhere in the C++ standard. This paragraph also >>>>> uses >>>>> "nontemplate function", which I assume refers to the same thing the C++ >>>>> standard spells "non-template function". So does "non-templatized >>>>> function" >>>>> also mean "non-template function"? Or does it have some other meaning? >>>> >>>> >>>> I would avoid "templatized" and believe "non-template function" is >>>> more appropriate in your example. >>> >>> >>> Yes, >>> >>> s/non-templatized/non-template/ >>> s/nontemplate/non-template/ >>> s/templatized function/function template/ >>> >>> But I wonder if that warning is even useful nowadays. The example of >>> "friend foo(int);" is bogus and is correctly rejected: >>> >>> fr.cc:2:17: error: ISO C++ forbids declaration of ‘foo’ with no type >>> [-fpermissive] >>> friend foo(int); >>> ^ >> >> >> I hadn't actually gotten that far :-) but it looks like that's an >> implicit-int error unrelated to the actual purpose of this option. >> >> This ended up on my todo list firstly because "templatized" didn't >> spell-check, and secondly because the "new compiler behavior" documented in >> connection with this option has existed at least since 1998 and can hardly >> be considered "new" any more. Also I think the reference to section 14.5.3 >> of the C++ standard is bit-rotten (it's 14.5.4 in the c++0x draft I have >> handy). >> >> I'll leave it up to the C++ experts to decide whether the option should just >> be removed and the warning replaced with a hard error controlled by some >> other flag. > > It definitely shouldn't be turned into a hard error, the warning > complains about valid code, such as: > > template<typename T> struct A { > friend int foo(T); > }; > > int main() { > A<int> a; > } > > I think it warns because the meaning of that code changed, a *long* > time ago, so it's saying "if you wrote this code in the 1990s it might > do something different to what you expect." > > I'm not sure how useful that warning is now, although EDG warns for it > too (with a fix-it hint that I think is bogus): > > "fr.cc", line 2: warning: "int foo(T)" declares a non-template function -- add > <> to refer to a template instance > friend int foo(T); > ^ That fix-it looks fine to me; it does seem odd for a template to declare as friend an open-ended family of overloaded functions. But I also am unsure how much of a problem this is for real code nowadays. Jason ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-15 15:53 ` Jason Merrill @ 2017-02-15 18:57 ` Jonathan Wakely 2017-02-15 20:17 ` Jason Merrill 0 siblings, 1 reply; 8+ messages in thread From: Jonathan Wakely @ 2017-02-15 18:57 UTC (permalink / raw) To: Jason Merrill; +Cc: Sandra Loosemore, Gerald Pfeifer, gcc On 15 February 2017 at 15:53, Jason Merrill wrote: > On Sat, Feb 11, 2017 at 4:19 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote: >> On 11 February 2017 at 20:36, Sandra Loosemore wrote: >>> On 02/11/2017 06:21 AM, Jonathan Wakely wrote: >>>> >>>> On 11 February 2017 at 08:48, Gerald Pfeifer wrote: >>>>> >>>>> On Fri, 10 Feb 2017, Sandra Loosemore wrote: >>>>>> >>>>>> The documentation for -Wno-non-template-friend refers to >>>>>> "non-templatized >>>>>> friend functions" and "templatized functions". I don't see the term >>>>>> "templatized" used anywhere in the C++ standard. This paragraph also >>>>>> uses >>>>>> "nontemplate function", which I assume refers to the same thing the C++ >>>>>> standard spells "non-template function". So does "non-templatized >>>>>> function" >>>>>> also mean "non-template function"? Or does it have some other meaning? >>>>> >>>>> >>>>> I would avoid "templatized" and believe "non-template function" is >>>>> more appropriate in your example. >>>> >>>> >>>> Yes, >>>> >>>> s/non-templatized/non-template/ >>>> s/nontemplate/non-template/ >>>> s/templatized function/function template/ >>>> >>>> But I wonder if that warning is even useful nowadays. The example of >>>> "friend foo(int);" is bogus and is correctly rejected: >>>> >>>> fr.cc:2:17: error: ISO C++ forbids declaration of ‘foo’ with no type >>>> [-fpermissive] >>>> friend foo(int); >>>> ^ >>> >>> >>> I hadn't actually gotten that far :-) but it looks like that's an >>> implicit-int error unrelated to the actual purpose of this option. >>> >>> This ended up on my todo list firstly because "templatized" didn't >>> spell-check, and secondly because the "new compiler behavior" documented in >>> connection with this option has existed at least since 1998 and can hardly >>> be considered "new" any more. Also I think the reference to section 14.5.3 >>> of the C++ standard is bit-rotten (it's 14.5.4 in the c++0x draft I have >>> handy). >>> >>> I'll leave it up to the C++ experts to decide whether the option should just >>> be removed and the warning replaced with a hard error controlled by some >>> other flag. >> >> It definitely shouldn't be turned into a hard error, the warning >> complains about valid code, such as: >> >> template<typename T> struct A { >> friend int foo(T); >> }; >> >> int main() { >> A<int> a; >> } >> >> I think it warns because the meaning of that code changed, a *long* >> time ago, so it's saying "if you wrote this code in the 1990s it might >> do something different to what you expect." >> >> I'm not sure how useful that warning is now, although EDG warns for it >> too (with a fix-it hint that I think is bogus): >> >> "fr.cc", line 2: warning: "int foo(T)" declares a non-template function -- add >> <> to refer to a template instance >> friend int foo(T); >> ^ > > That fix-it looks fine to me; Where should I add the <> to make it valid? If I change the example to "friend int foo<>(T);" EDG says it's not a template: template<typename T> struct A { friend int foo<>(T); }; int main() { A<int> a; } "fr.cc", line 2: error: foo is not a template friend int foo<>(T); ^ 1 error detected in the compilation of "edg.cc". I don't think I understand what this kind of friend declarationdoes, or what the warning is for, so if you think it's still useful I'm happy with that :-) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Doc question: is "templatized" a word? 2017-02-15 18:57 ` Jonathan Wakely @ 2017-02-15 20:17 ` Jason Merrill 0 siblings, 0 replies; 8+ messages in thread From: Jason Merrill @ 2017-02-15 20:17 UTC (permalink / raw) To: Jonathan Wakely; +Cc: Sandra Loosemore, Gerald Pfeifer, gcc On Wed, Feb 15, 2017 at 1:57 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote: > On 15 February 2017 at 15:53, Jason Merrill wrote: >> On Sat, Feb 11, 2017 at 4:19 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote: >>> On 11 February 2017 at 20:36, Sandra Loosemore wrote: >>>> On 02/11/2017 06:21 AM, Jonathan Wakely wrote: >>>>> >>>>> On 11 February 2017 at 08:48, Gerald Pfeifer wrote: >>>>>> >>>>>> On Fri, 10 Feb 2017, Sandra Loosemore wrote: >>>>>>> >>>>>>> The documentation for -Wno-non-template-friend refers to >>>>>>> "non-templatized >>>>>>> friend functions" and "templatized functions". I don't see the term >>>>>>> "templatized" used anywhere in the C++ standard. This paragraph also >>>>>>> uses >>>>>>> "nontemplate function", which I assume refers to the same thing the C++ >>>>>>> standard spells "non-template function". So does "non-templatized >>>>>>> function" >>>>>>> also mean "non-template function"? Or does it have some other meaning? >>>>>> >>>>>> >>>>>> I would avoid "templatized" and believe "non-template function" is >>>>>> more appropriate in your example. >>>>> >>>>> >>>>> Yes, >>>>> >>>>> s/non-templatized/non-template/ >>>>> s/nontemplate/non-template/ >>>>> s/templatized function/function template/ >>>>> >>>>> But I wonder if that warning is even useful nowadays. The example of >>>>> "friend foo(int);" is bogus and is correctly rejected: >>>>> >>>>> fr.cc:2:17: error: ISO C++ forbids declaration of ‘foo’ with no type >>>>> [-fpermissive] >>>>> friend foo(int); >>>>> ^ >>>> >>>> >>>> I hadn't actually gotten that far :-) but it looks like that's an >>>> implicit-int error unrelated to the actual purpose of this option. >>>> >>>> This ended up on my todo list firstly because "templatized" didn't >>>> spell-check, and secondly because the "new compiler behavior" documented in >>>> connection with this option has existed at least since 1998 and can hardly >>>> be considered "new" any more. Also I think the reference to section 14.5.3 >>>> of the C++ standard is bit-rotten (it's 14.5.4 in the c++0x draft I have >>>> handy). >>>> >>>> I'll leave it up to the C++ experts to decide whether the option should just >>>> be removed and the warning replaced with a hard error controlled by some >>>> other flag. >>> >>> It definitely shouldn't be turned into a hard error, the warning >>> complains about valid code, such as: >>> >>> template<typename T> struct A { >>> friend int foo(T); >>> }; >>> >>> int main() { >>> A<int> a; >>> } >>> >>> I think it warns because the meaning of that code changed, a *long* >>> time ago, so it's saying "if you wrote this code in the 1990s it might >>> do something different to what you expect." >>> >>> I'm not sure how useful that warning is now, although EDG warns for it >>> too (with a fix-it hint that I think is bogus): >>> >>> "fr.cc", line 2: warning: "int foo(T)" declares a non-template function -- add >>> <> to refer to a template instance >>> friend int foo(T); >>> ^ >> >> That fix-it looks fine to me; > > Where should I add the <> to make it valid? > > If I change the example to "friend int foo<>(T);" EDG says it's not a template: > > template<typename T> struct A { > friend int foo<>(T); > }; > > int main() { > A<int> a; > } > > "fr.cc", line 2: error: foo is not a template > friend int foo<>(T); Yep, you would also need to declare the foo template earlier in the TU. Jason ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-02-15 20:17 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-11 4:11 Doc question: is "templatized" a word? Sandra Loosemore 2017-02-11 8:48 ` Gerald Pfeifer 2017-02-11 13:21 ` Jonathan Wakely 2017-02-11 20:36 ` Sandra Loosemore 2017-02-11 21:20 ` Jonathan Wakely 2017-02-15 15:53 ` Jason Merrill 2017-02-15 18:57 ` Jonathan Wakely 2017-02-15 20:17 ` Jason Merrill
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).