From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C7CFD385DC00; Tue, 2 Jun 2020 20:14:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7CFD385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591128882; bh=ZhzbHzYGEHkil9zRTPBo3GX6TPW8vS/I2buGrP5SAvk=; h=From:To:Subject:Date:From; b=l/6jthzO2qpPRVZFnUpjEsX0roy4HshUNfF2cQysDTbSrW7IdtlkuIfMIPuRUosf4 dVHaZjJGUdXLzT9+4absqGpr6C6KR/9WNl3VaJYGjG+tkuKHmvzoHgTamDACUPB+yE qnsFOo6Vc3em9rJN4m/8hDs8N36wi4VxdnBlkYZs= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95485] New: missing warning writing into function text Date: Tue, 02 Jun 2020 20:14:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 20:14:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95485 Bug ID: 95485 Summary: missing warning writing into function text Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC doesn't diagnose attempts to write into functions, even though those wi= ll in all likelihood crash with a SIGBUS at runtime. For example, in the following snippet the destination of the memset call is= a function rather than the memory it was called to obtain. The memset call should be diagnosed. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-optimized=3D/dev/stdout z.c typedef void* F (int); void* f (F *p) { void *q =3D p (32); // allocate memory __builtin_memset (p, 0, 32); // zero out -- whoops! -- writing to a function return q; // return "clear" memory } ;; Function f (f, funcdef_no=3D0, decl_uid=3D1933, cgraph_uid=3D1, symbol_o= rder=3D0) f (void * (*) (int) p) { void * q; [local count: 1073741824]: q_4 =3D p_2(D) (32); __builtin_memset (p_2(D), 0, 32); return q_4; } Two compilers on Godbolt diagnose the code: Visual C++: z.c(8): warning C4152: nonstandard extension, function/data pointer convers= ion in expression and the Small Device C Compiler (SDCC): x.c:8: warning 244: pointer types incompatible=20 from type 'void generic* function ( int fixed) code* fixed' to type 'void generic* fixed'=