Re: Quick C++ question for C++ experts :)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1 April 2015 at 14:32, Jonathan Wakely <jwakely@xxxxxxxxxx> wrote:
> On 28/03/15 16:45 -0300, Paulo César Pereira de Andrade wrote:
>>
>> 2015-03-28 16:06 GMT-03:00 Paulo César Pereira de Andrade
>> <paulo.cesar.pereira.de.andrade@xxxxxxxxx>:
>>>
>>> Is this expected to not compile with -fno-implicit-templates?
>>>
>>> ---%<---
>>> $ cat test.cc
>>> #include <string>
>>> std::string test(int i)
>>> {
>>>     std::string t;
>>>     std::string s = "(";
>>>     t = "";
>>>     for (int r = i; r; r>>=1) {
>>>         if (r & 1)
>>>             t = "1" + t;
>>>         else
>>>             t = "0" + t;
>>>     }
>>>     s += t;
>>>     s += ")";
>>>     return s;
>>> }
>>>
>>> int
>>> main(int argc, char *argv[])
>>> {
>>>     std::string s = test(16);
>>>     return 0;
>>> }
>>>

> As I stated in the bug report, the code is invalid, but used to work
> due to an undocumented "accidental" feature of libstdc++.so which
> happens to provide instantiations of the required operator+().
>
> If you use -fno-implicit-templates then it is your responsibility to
> instantiate all the templates you use. The program uses operator+()
> without instantiating it, so the program is wrong. (It also uses a
> number of other templates without instantiating them, which is also
> wrong).
>

Do you mind clarifying? I thought <string> should provide that
http://www.cplusplus.com/reference/string/string/operator+/ or is that
what fno-implicit-templates is turning off?

-- 
imalone
http://ibmalone.blogspot.co.uk
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux