delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/06/22/12:13:48

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Reply-To: Cygwin List <cygwin AT cygwin DOT com>
Message-Id: <6.1.0.6.0.20040622120448.0322ec68@pop.prospeed.net>
X-Sender:
Date: Tue, 22 Jun 2004 12:07:07 -0400
To: "Alex Vinokur" <alexvn AT connect DOT to>, cygwin AT cygwin DOT com
From: Larry Hall <cygwin-lh AT cygwin DOT com>
Subject: Re: gcc -mno-cygwin foo.c & gcc foo.c generate different behavior
In-Reply-To: <cb9lec$ueu$1@sea.gmane.org>
References: <cb9lec$ueu$1 AT sea DOT gmane DOT org>
Mime-Version: 1.0

At 12:06 PM 6/22/2004, you wrote:
>====================
>Windows 2000
>CYGWIN_NT-5.0 1.5.10-3 (0.116/4/2)
>gcc (GCC) 3.3.1 (cygming special)
>====================
>
>
>
>------ foo.c ------
>
>#include <stdio.h>
>
>struct foo
>{
>  char* bar_;
>};
>
>int main()
>{
>char* ch = "ABC";
>struct foo* f;
>
>  f->bar_ = ch;  /* gcc foo.c : Segmentation fault */
>  printf("start\n");
>  printf("---> %s\n", f->bar_);
>  printf("finish\n");
>
>  return 0;
>
>}
>
>-------------------
>
>$ gcc -mno-cygwin foo.c
>
>$ a
>start
>---> ABC
>finish
>
>$ cygcheck a
>Found: .\a.exe
>a.exe
>  C:\WINNT\system32\msvcrt.dll
>    C:\WINNT\system32\KERNEL32.dll
>      C:\WINNT\system32\NTDLL.DLL
>
>
>$ gcc foo.c
>
>$ a
>Segmentation fault (core dumped)
>
>$ cygcheck a
>Found: .\a.exe
>a.exe
>  C:\cygwin\bin\cygwin1.dll
>    C:\WINNT\system32\ADVAPI32.DLL
>      C:\WINNT\system32\NTDLL.DLL
>      C:\WINNT\system32\KERNEL32.DLL
>      C:\WINNT\system32\RPCRT4.DLL
>


Incorrect code has a way of generating undefined behavior.

Did you expect this to work?


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019