| 
 
Archives
 
D Programming 
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming 
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript  | 
c++ - [bug] string literals should be const
 
According section 2.13.4 of the standard, a string literal has type 
"array of n const char". So this should work:
   template <class T>
   void test(T x)
   {
       char const* y;
       T z = y;
   }
   int main()
   {
       test("xxxx");
   }
Although, section 4.2 specifies that a conversion is allowed to a 
non-const pointer. So this is still allowed:
   char* p = "abc";
But that's deprecated according to Annex D. It's also mentioned in C.1.1.
Daniel
 Jun 28 2005
 
 |