www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 260] New: Underlying D string types should match correct lengths.

https://bugzilla.gdcproject.org/show_bug.cgi?id=260

            Bug ID: 260
           Summary: Underlying D string types should match correct
                    lengths.
           Product: GDC
           Version: development
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
          Assignee: ibuclaw gdcproject.org
          Reporter: ibuclaw gdcproject.org

---

import gcc.builtins;

char *foo(char *buffer)
{
  return __builtin_strcat (&buffer[0], "Li");
}

---

$ gdc test.d -Werror
test.d: In function ‘foo’:
test.d:5:3: error: ‘__builtin_memcpy’ reading 3 bytes from a region of size
2
[-Werror=stringop-overflow=]
   return __builtin_strcat (&buffer[0], "Li");
   ^
cc1d: all warnings being treated as errors

---

This happens because although "Li" is a null terminated string, we give it the
type char[2]*.

-- 
You are receiving this mail because:
You are watching all bug changes.
Jun 07