From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28716 invoked by alias); 18 Dec 2013 12:25:34 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 28706 invoked by uid 89); 18 Dec 2013 12:25:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,SPF_SOFTFAIL,URI_HEX autolearn=no version=3.3.2 X-HELO: sam.nabble.com Received: from sam.nabble.com (HELO sam.nabble.com) (216.139.236.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 18 Dec 2013 12:25:32 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VtGBe-0001n2-3a for gcc-help@gcc.gnu.org; Wed, 18 Dec 2013 04:25:14 -0800 Date: Wed, 18 Dec 2013 12:25:00 -0000 From: buzush To: gcc-help@gcc.gnu.org Message-ID: <1387369514104-996603.post@n5.nabble.com> Subject: function cast leads to gcc abort command MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2013-12/txt/msg00123.txt.bz2 hi, in the following code func.c : #include int Myfunc1(int i, int z) { return i; } int main() { int ans; /* casting the function into an 'int (int)' function */ ans = ((int(*)(int))(Myfunc1))(5); printf("ans: %d\n\n", ans); return 0; } i tried to cast an int(int,int) function into an int(int) function an got the gcc warning and note: func.c:13:32: warning: function called through a non-compatible type [enabled by default] func.c:13:32: note: if this code is reached, the program will abort and when trying to run i get: Illegal instruction (core dumped) (but if i compile this file with a .cpp ending with the gcc compiler it works OK.) can anyone explain the problem of the compiler in the .c case? -- View this message in context: http://gcc.1065356.n5.nabble.com/function-cast-leads-to-gcc-abort-command-tp996603.html Sent from the gcc - Help mailing list archive at Nabble.com.