www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - weird linux behavior

I don't know if I should post it in the bugs ng because I'm not sure 
what's going on.

This program compiles successfully on DMD linux, gdc linux and gdc 
cygwin, but only runs ok on cygwin:

const int SYS_NMLN=65;    // 20 on cygwin

     struct utsname
         char sysname[SYS_NMLN];
         char nodename[SYS_NMLN];
         char release[SYS_NMLN];
         char vers[SYS_NMLN];
         char machine[SYS_NMLN];

     int uname (utsname *);

import std.stdio;

void main ()
     //utsname* name = new utsname;      // line 21
     //int res = uname(name);            // line 22
     utsname name;                     // line 23
     int res = uname(&name);           // line 24
     if (res==0)

As is, it segfaults at the end, after the final writefln(). If I comment 
lines 23 and 24 and uncomment lines 21 and 22, it runs correctly. gdb 
doesn't give any additional information about what happens. Does anybody 
have a clue of what could be happening?

Carlos Santander Bernal
Mar 05 2005