www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3046] New: Segfault with C++ static variable

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3046

           Summary: Segfault with C++ static variable
           Product: D
           Version: 2.030
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: rsinfu gmail.com


The compiler segfaults compiling this invalid code:
--------------------
class C
{
extern(C++):
    static int var; // C++ variable should be error
}
--------------------

The segfault happend in cpp_mangle_name() (cppmangle.c):
--------------------
    FuncDeclaration *fd = s->isFuncDeclaration();
    if (fd->isConst())  <-- HERE
        buf->writeByte('K');
--------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 02 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3046


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au





I can't reproduce this. It works for me on Windows. Is it Linux only, or is
something missing from the test case?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3046






---

 I can't reproduce this. It works for me on Windows. Is it Linux only, or is
 something missing from the test case?
It's Linux only. On Linux, C++ name mangling is done by the front end. The front end assumes that extern(C++) is applied only to a function, and segfaults when extern(C++) is applied to a static variable. On Windows, C++ name mangling is done by the backend, which can deal with C++ variable name mangling. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3046


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



Patch: cpp_mangle.c, cpp_mangle_name(), line 112.


        FuncDeclaration *fd = s->isFuncDeclaration();
+        if (!fd)
+        {
+            s->error("cannot be declared as extern(C++)");
+            return;
+        }
        if (fd->isConst())
            buf->writeByte('K');

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3046


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



15:09:43 PDT ---
http://www.dsource.org/projects/dmd/changeset/647

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010