get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2225391/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2225391,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2225391/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/CAAAu3XuOCu=khHPB4OvPjTF5N7n1vuoeTzn_ANn_C0onRLiX=Q@mail.gmail.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api",
        "name": "GNU Compiler Collection",
        "link_name": "gcc",
        "list_id": "gcc-patches.gcc.gnu.org",
        "list_email": "gcc-patches@gcc.gnu.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null
    },
    "msgid": "<CAAAu3XuOCu=khHPB4OvPjTF5N7n1vuoeTzn_ANn_C0onRLiX=Q@mail.gmail.com>",
    "date": "2026-04-20T23:37:31",
    "name": "c-family: Emit -Wsizeof-pointer-memaccess even without builtin recognition",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "4fa9f6ad1019253b2027596079f181f5be2dbacb",
    "submitter": {
        "id": 93197,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/93197/?format=api",
        "name": "Naveen Iyer",
        "email": "iyernaveenr@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/CAAAu3XuOCu=khHPB4OvPjTF5N7n1vuoeTzn_ANn_C0onRLiX=Q@mail.gmail.com/mbox/",
    "series": [
        {
            "id": 500695,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/500695/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500695",
            "date": "2026-04-20T23:37:31",
            "name": "c-family: Emit -Wsizeof-pointer-memaccess even without builtin recognition",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/500695/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2225391/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2225391/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "gcc-patches@gcc.gnu.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "gcc-patches@gcc.gnu.org"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Y04JTTC7;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)",
            "sourceware.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=Y04JTTC7",
            "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com",
            "sourceware.org; spf=pass smtp.mailfrom=gmail.com",
            "server2.sourceware.org;\n arc=pass smtp.remote-ip=209.85.215.178"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g023v1tkWz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 09:38:17 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 273934D108C0\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 23:38:15 +0000 (GMT)",
            "from mail-pg1-f178.google.com (mail-pg1-f178.google.com\n [209.85.215.178])\n by sourceware.org (Postfix) with ESMTPS id CCED14A9933E\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 23:37:44 +0000 (GMT)",
            "by mail-pg1-f178.google.com with SMTP id\n 41be03b00d2f7-c7961d7bc09so1295101a12.1\n for <gcc-patches@gcc.gnu.org>; Mon, 20 Apr 2026 16:37:44 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 273934D108C0",
            "OpenDKIM Filter v2.11.0 sourceware.org CCED14A9933E"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org CCED14A9933E",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org CCED14A9933E",
        "ARC-Seal": [
            "i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1776728265; cv=pass;\n b=EU6Pq3dt67N+wuhnIuTeczIDtRlVqZMGDMWGvjJg6VSVQDk6x5aVtNx4HLcbDq/n+qreagDN7oWCOUl7Uj7kccxATP/dysY/W9Pysghd2c0ISNgEmrI7yl2AmefprRgBxoCJ03hDkPvK7QZzb+YGHIkFzxtm8fb16DCbznW+pFo=",
            "i=1; a=rsa-sha256; t=1776728263; cv=none;\n d=google.com; s=arc-20240605;\n b=aPKjHNjSG3cPnqYKKXsz/Z9MicbJuHOXtC2mEGzXLm/FOvTvKPEtVK5io5N7Jc/GG6\n dFEmQZkAUZjYyHW10MuFz6yOSi/mTIYN2ZYTPkAmT2g2k/ynM54Qh7c/+BMcRPQjaAuY\n Oiq4ygZae7lf+hou0yrzvT2/8hIVOK+4eZQJBxQVmgUorggUsC14zKp+bGUb+gLqNiCO\n gBo5fEpu/u2SDM16yjH5REJ38iuvwEyuvK1i4qmZEXpYWZ5byX8P55hvv6DGXb6BYM/G\n CbBXxA9Vt3Iw/1L8EvE4l39bXytRqYdPrrO8SviYCLYZcvhR48mpcSiHDfaYX0Blp0Dd\n jz5Q=="
        ],
        "ARC-Message-Signature": [
            "i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776728265; c=relaxed/simple;\n bh=bHOYx8vrRPJ9x6TkWbIpnk3sNB9TkqfX+B+25nEm8FY=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=qNQTO1s+2/t9Ax1lfDxtkjOVJ4V8gLGspWYDh89dFOfXEGiDCcmzJPXrx5dCSEtrhGWpcXqA1ZRieae1Cfsp9IMt/97bKK76y/Lh6/pGk3G8j+HD/1Y59dT19KLF8KDcQVIKB0Me5Z9zvk5YyD37dNKOZrx48EnhQVCTitKEASw=",
            "i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=cc:to:subject:message-id:date:from:mime-version:dkim-signature;\n bh=5YpEUJG6IERiNynDD95BjjWHocfREErMmPiLkbMo4x8=;\n fh=woc/vFI9y7y337SZdQihgcS9PuULONqy4rCOSvGrwrE=;\n b=EdCzhpTDaE/OQZnmGPRRQ/Pidssks3RwWHEy9yZoS2PoWE1XcswjvZ063/o6JbKViH\n x2PqG+ocg7JkDBbAnl81Ih9U0NBF7M4lEhW9LtSTCSljd6v4+wSzW13ay/NfCN/Uen4f\n tn+AjaAJU9JE2uX9UgRQPMqMqpj9JGGbU7RcfuJB2O/F/+MLF/UVCJtVhMFEzHCwsKJx\n XtzNr+uzL0i7vngNn8f13B4FnvcY3VYElh68eH5hqui7WYZvuHzYAfBcsJ8Ip9350F4g\n YmE9Mi9/QZ8ydpTj8C42zchYUw/xBWZLZlRGdEwSeb/KTMQxj9Jm0DRxQ0BzrPZyYtcf\n sjJw==; darn=gcc.gnu.org"
        ],
        "ARC-Authentication-Results": [
            "i=2; server2.sourceware.org",
            "i=1; mx.google.com; arc=none"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1776728263; x=1777333063; darn=gcc.gnu.org;\n h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject\n :date:message-id:reply-to;\n bh=5YpEUJG6IERiNynDD95BjjWHocfREErMmPiLkbMo4x8=;\n b=Y04JTTC7BTq9QZd/P+6etAQQBLyHalUpaIra+QcKHQYu+z6OppOiFGzV3yuniQdKlg\n OzNJ6XqPe3uAkCK64su+v+6fYV8r8onEZYIdnWPCt+Vsv/0xKwbub/PA/0tucplfe+r3\n fPmjUPG7gHr2jyd2pFEWtpR3WVDY1s70VP7Hh+3xyPVbjc9qyZ1DWFYX+PlHm7grAzxh\n it+SS4epZr4ALF319z3TUSNPtB99SO7xTaiP0LjE1siQIScetFiGSeLAgPFckRhLepkx\n XXIsSLnQK/SeIvpsmimQMQXiPFlYlu/5i8VrX/mGho8OxkiiUrcJzmohhrMvyY0uXvEh\n ohwQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776728263; x=1777333063;\n h=cc:to:subject:message-id:date:from:mime-version:x-gm-gg\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=5YpEUJG6IERiNynDD95BjjWHocfREErMmPiLkbMo4x8=;\n b=rJ83pgybPIpNv7/OftJxGswNGaavv20xKlHOlshpWm4bq3OWrzJlLn99j3kHSF600G\n M0MK+xWO5jm3cTlkknqBfLL5Pd/tcvSQVqPSgzMBFTnBw/yoKsQz3b82QbiLTU2DMhYU\n skLRDBKmGlOHwehVe0VNC3usfo6tZy9yNHsqk4esC1zrzElSSQROSCspwII7trJg9aze\n +PuhT5iCDTqnvmtaKIlzXWccUhhz92465bUl3sS7B6OZu1MHUp8hL+UFUYDDA91cUbcw\n ojFkmX0K3DNDRsbikZZYZdCLwAq/26bhCTlpaPqhxUPV/8YimyeRKer2ZVUewA5Z9ivM\n hmkw==",
        "X-Gm-Message-State": "AOJu0Yzp4l2S4sItNS8tWU+PGlrbFhoQuHsCdbSxRnHRirVIJHa3sdCK\n CFQ6+SRR7uw2Xw7dr30VTl9NtJtG8V45nkHpyyIYQwwYuLr2RbM1mLyoQ/fcn/niNHlJcXsJMf8\n 1VdFavI0HRLe4sARvz3U3ChaZ4uhJ2tmS6X8X",
        "X-Gm-Gg": "AeBDieveNM07RmBVE5AioaEvDRMPA4GvJx15afFHtuYiLkDRW0RMDSw9gCt5kJkwZMS\n Q8f6GXtp8xBxpcLRPBnlaD/TPZBex7Wij94IB2jpVmvI4Deb6YmgM+3J6I+PWWgnvZIMy96UikG\n Bq7wSZRy7r6xFngjoQWrP2E/doJPO8+w0F9ER2GRxUSBfDvr40kEJlTio70JWlnUieTDFLCsj8L\n Wr56YoXCHpH2NkQ+FnCdszcb1tpkYwb8rNBrlDnMrWl2BVsMTKteTjzLsUCJ2Fn7IGYwGfm5NdT\n tJO4X+12fgczkTfxytYswB0//9ExmqkKUBNT6SY/MMlvCgVwQDKze82r+R323gUW8a52OGuL5MM\n ZvuMxU3b9XYFaJvludK3Yad3zxkwkGUf1PPqqNA==",
        "X-Received": "by 2002:a05:6a20:1581:b0:39b:81bf:15ed with SMTP id\n adf61e73a8af0-3a08d9038b6mr17496051637.52.1776728263373; Mon, 20 Apr 2026\n 16:37:43 -0700 (PDT)",
        "MIME-Version": "1.0",
        "From": "Naveen Iyer <iyernaveenr@gmail.com>",
        "Date": "Mon, 20 Apr 2026 18:37:31 -0500",
        "X-Gm-Features": "AQROBzAOS2xqyNAAfMJsEPZm_cof0WxVrQN_CMy_zjSZZ6WcgpI6-ZLWGWOsm8w",
        "Message-ID": "\n <CAAAu3XuOCu=khHPB4OvPjTF5N7n1vuoeTzn_ANn_C0onRLiX=Q@mail.gmail.com>",
        "Subject": "[PATCH] c-family: Emit -Wsizeof-pointer-memaccess even without\n builtin recognition",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "Naveen Iyer <iyernaveenr@gmail.com>",
        "Content-Type": "multipart/mixed; boundary=\"00000000000000592a064fecc9c5\"",
        "X-BeenThere": "gcc-patches@gcc.gnu.org",
        "X-Mailman-Version": "2.1.30",
        "Precedence": "list",
        "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>",
        "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>",
        "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>",
        "List-Post": "<mailto:gcc-patches@gcc.gnu.org>",
        "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>",
        "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>",
        "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"
    },
    "content": "GCC's -Wsizeof-pointer-memaccess warning does not fire when -fno-builtin\nis used, because sizeof_pointer_memaccess_warning in c-warn.cc bails out\nearly when the callee is not recognized as a built-in via\nfndecl_built_in_p().  This means embedded and freestanding code compiled\nwith -fno-builtin silently misses sizeof(pointer) bugs in memcpy, memset,\nmemmove, and other memory/string function calls.\n\nThis patch adds a fallback path that matches by function name when the\ncallee is not recognized as a built-in, so the diagnostic fires regardless\nof -fno-builtin.\n\nTested on x86_64-pc-linux-gnu with no regressions.\n\nBootstrapped and tested with make check-gcc\nRUNTESTFLAGS=\"dg.exp=Wsizeof-pointer-memaccess*.c\" -- 299 expected passes,\n12 expected failures (all pre-existing), zero unexpected failures.\n\nI believe this qualifies as a small change under the FSF copyright\nassignment exemption.  Please let me know if a copyright assignment is\nrequired.\n\nThanks,\nNaveen",
    "diff": "From 5a0f4f41a3d2209d28faff0e29ad73d1a0cb1b0d Mon Sep 17 00:00:00 2001\nFrom: \"Naveen R. Iyer\" <iyernaveenr@gmail.com>\nDate: Mon, 20 Apr 2026 18:16:47 -0500\nSubject: [PATCH] c-family: Emit -Wsizeof-pointer-memaccess even without\n builtin recognition\n\nWhen -fno-builtin is in effect, functions like memcpy, memset, and\nmemmove are not recognized as built-in functions, causing\nsizeof_pointer_memaccess_warning to bail out early and silently\nsuppress the diagnostic.  This is a problem for embedded and\nfreestanding code compiled with -fno-builtin, where sizeof(pointer)\nbugs in memory and string function calls go undetected.\n\nAdd a fallback path that matches by function name when the callee\nis not recognized as a built-in, so the warning fires regardless\nof -fno-builtin.\n\ngcc/c-family/ChangeLog:\n\n* c-warn.cc (sizeof_pointer_memaccess_warning): When the callee\nis not a recognized built-in, fall back to matching by function\nname for the set of memory and string functions covered by\n-Wsizeof-pointer-memaccess.  Replace use of fncode for the\nBUILT_IN_STRNDUP exclusion with a bool flag.\n\ngcc/testsuite/ChangeLog:\n\n* c-c++-common/Wsizeof-pointer-memaccess5.c: New test.\n---\n gcc/c-family/c-warn.cc                        | 242 ++++++++++++------\n .../c-c++-common/Wsizeof-pointer-memaccess5.c |  40 +++\n 2 files changed, 210 insertions(+), 72 deletions(-)\n create mode 100644 gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess5.c\n\ndiff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc\nindex 8fc0d8a53b35..f19deda8d17f 100644\n--- a/gcc/c-family/c-warn.cc\n+++ b/gcc/c-family/c-warn.cc\n@@ -782,87 +782,185 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,\n {\n   tree type, dest = NULL_TREE, src = NULL_TREE, tem;\n   bool strop = false, cmp = false;\n+  bool is_strndup = false;\n   unsigned int idx = ~0;\n   location_t loc;\n \n   if (TREE_CODE (callee) != FUNCTION_DECL\n-      || !fndecl_built_in_p (callee, BUILT_IN_NORMAL)\n       || vec_safe_length (params) <= 1)\n     return;\n \n-  enum built_in_function fncode = DECL_FUNCTION_CODE (callee);\n-  switch (fncode)\n+  if (fndecl_built_in_p (callee, BUILT_IN_NORMAL))\n     {\n-    case BUILT_IN_STRNCMP:\n-    case BUILT_IN_STRNCASECMP:\n-      cmp = true;\n-      /* FALLTHRU */\n-    case BUILT_IN_STRNCPY:\n-    case BUILT_IN_STRNCPY_CHK:\n-    case BUILT_IN_STRNCAT:\n-    case BUILT_IN_STRNCAT_CHK:\n-    case BUILT_IN_STPNCPY:\n-    case BUILT_IN_STPNCPY_CHK:\n-      strop = true;\n-      /* FALLTHRU */\n-    case BUILT_IN_MEMCPY:\n-    case BUILT_IN_MEMCPY_CHK:\n-    case BUILT_IN_MEMMOVE:\n-    case BUILT_IN_MEMMOVE_CHK:\n-      if (params->length () < 3)\n-\treturn;\n-      src = (*params)[1];\n-      dest = (*params)[0];\n-      idx = 2;\n-      break;\n-    case BUILT_IN_BCOPY:\n-      if (params->length () < 3)\n-\treturn;\n-      src = (*params)[0];\n-      dest = (*params)[1];\n-      idx = 2;\n-      break;\n-    case BUILT_IN_MEMCMP:\n-    case BUILT_IN_BCMP:\n-      if (params->length () < 3)\n-\treturn;\n-      src = (*params)[1];\n-      dest = (*params)[0];\n-      idx = 2;\n-      cmp = true;\n-      break;\n-    case BUILT_IN_MEMSET:\n-    case BUILT_IN_MEMSET_CHK:\n-      if (params->length () < 3)\n+      enum built_in_function fncode = DECL_FUNCTION_CODE (callee);\n+      switch (fncode)\n+\t{\n+\tcase BUILT_IN_STRNCMP:\n+\tcase BUILT_IN_STRNCASECMP:\n+\t  cmp = true;\n+\t  /* FALLTHRU */\n+\tcase BUILT_IN_STRNCPY:\n+\tcase BUILT_IN_STRNCPY_CHK:\n+\tcase BUILT_IN_STRNCAT:\n+\tcase BUILT_IN_STRNCAT_CHK:\n+\tcase BUILT_IN_STPNCPY:\n+\tcase BUILT_IN_STPNCPY_CHK:\n+\t  strop = true;\n+\t  /* FALLTHRU */\n+\tcase BUILT_IN_MEMCPY:\n+\tcase BUILT_IN_MEMCPY_CHK:\n+\tcase BUILT_IN_MEMMOVE:\n+\tcase BUILT_IN_MEMMOVE_CHK:\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t  break;\n+\tcase BUILT_IN_BCOPY:\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[0];\n+\t  dest = (*params)[1];\n+\t  idx = 2;\n+\t  break;\n+\tcase BUILT_IN_MEMCMP:\n+\tcase BUILT_IN_BCMP:\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t  cmp = true;\n+\t  break;\n+\tcase BUILT_IN_MEMSET:\n+\tcase BUILT_IN_MEMSET_CHK:\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t  break;\n+\tcase BUILT_IN_BZERO:\n+\t  dest = (*params)[0];\n+\t  idx = 1;\n+\t  break;\n+\tcase BUILT_IN_STRNDUP:\n+\t  src = (*params)[0];\n+\t  strop = true;\n+\t  is_strndup = true;\n+\t  idx = 1;\n+\t  break;\n+\tcase BUILT_IN_MEMCHR:\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[0];\n+\t  idx = 2;\n+\t  break;\n+\tcase BUILT_IN_SNPRINTF:\n+\tcase BUILT_IN_SNPRINTF_CHK:\n+\tcase BUILT_IN_VSNPRINTF:\n+\tcase BUILT_IN_VSNPRINTF_CHK:\n+\t  dest = (*params)[0];\n+\t  idx = 1;\n+\t  strop = true;\n+\t  break;\n+\tdefault:\n+\t  break;\n+\t}\n+    }\n+  else\n+    {\n+      /* When -fno-builtin is in effect, the callee is not recognized as\n+\t a built-in.  Fall back to matching by function name so that\n+\t -Wsizeof-pointer-memaccess still fires.  */\n+      tree id = DECL_NAME (callee);\n+      if (!id)\n \treturn;\n-      dest = (*params)[0];\n-      idx = 2;\n-      break;\n-    case BUILT_IN_BZERO:\n-      dest = (*params)[0];\n-      idx = 1;\n-      break;\n-    case BUILT_IN_STRNDUP:\n-      src = (*params)[0];\n-      strop = true;\n-      idx = 1;\n-      break;\n-    case BUILT_IN_MEMCHR:\n-      if (params->length () < 3)\n+      const char *name = IDENTIFIER_POINTER (id);\n+      if (strcmp (name, \"strncmp\") == 0\n+\t  || strcmp (name, \"strncasecmp\") == 0)\n+\t{\n+\t  cmp = true;\n+\t  strop = true;\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"strncpy\") == 0\n+\t       || strcmp (name, \"strncat\") == 0\n+\t       || strcmp (name, \"stpncpy\") == 0)\n+\t{\n+\t  strop = true;\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"memcpy\") == 0\n+\t       || strcmp (name, \"memmove\") == 0)\n+\t{\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"bcopy\") == 0)\n+\t{\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[0];\n+\t  dest = (*params)[1];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"memcmp\") == 0\n+\t       || strcmp (name, \"bcmp\") == 0)\n+\t{\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[1];\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t  cmp = true;\n+\t}\n+      else if (strcmp (name, \"memset\") == 0)\n+\t{\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  dest = (*params)[0];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"bzero\") == 0)\n+\t{\n+\t  dest = (*params)[0];\n+\t  idx = 1;\n+\t}\n+      else if (strcmp (name, \"strndup\") == 0)\n+\t{\n+\t  src = (*params)[0];\n+\t  strop = true;\n+\t  is_strndup = true;\n+\t  idx = 1;\n+\t}\n+      else if (strcmp (name, \"memchr\") == 0)\n+\t{\n+\t  if (params->length () < 3)\n+\t    return;\n+\t  src = (*params)[0];\n+\t  idx = 2;\n+\t}\n+      else if (strcmp (name, \"snprintf\") == 0\n+\t       || strcmp (name, \"vsnprintf\") == 0)\n+\t{\n+\t  dest = (*params)[0];\n+\t  idx = 1;\n+\t  strop = true;\n+\t}\n+      else\n \treturn;\n-      src = (*params)[0];\n-      idx = 2;\n-      break;\n-    case BUILT_IN_SNPRINTF:\n-    case BUILT_IN_SNPRINTF_CHK:\n-    case BUILT_IN_VSNPRINTF:\n-    case BUILT_IN_VSNPRINTF_CHK:\n-      dest = (*params)[0];\n-      idx = 1;\n-      strop = true;\n-      break;\n-    default:\n-      break;\n     }\n \n   if (idx >= 3)\n@@ -886,7 +984,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,\n \t argument rather than the destination unless they are equal\n \t to one another.  Handle constant sizes and also try to handle\n \t sizeof expressions involving VLAs.  */\n-      if (strop && !cmp && fncode != BUILT_IN_STRNDUP && src)\n+      if (strop && !cmp && !is_strndup && src)\n \t{\n \t  tem = tree_strip_nop_conversions (src);\n \t  if (TREE_CODE (tem) == ADDR_EXPR)\ndiff --git a/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess5.c b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess5.c\nnew file mode 100644\nindex 000000000000..5f4ad38f5f7b\n--- /dev/null\n+++ b/gcc/testsuite/c-c++-common/Wsizeof-pointer-memaccess5.c\n@@ -0,0 +1,40 @@\n+/* Test -Wsizeof-pointer-memaccess warnings with -fno-builtin.  */\n+/* { dg-do compile } */\n+/* { dg-options \"-Wall -fno-builtin\" } */\n+\n+typedef __SIZE_TYPE__ size_t;\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+extern void *memcpy (void *, const void *, size_t);\n+extern void *memmove (void *, const void *, size_t);\n+extern void *memset (void *, int, size_t);\n+extern char *strncpy (char *, const char *, size_t);\n+extern char *strncat (char *, const char *, size_t);\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+struct A { int x; int y; };\n+\n+void\n+f1 (struct A *dst, const struct A *src)\n+{\n+  memcpy (dst, src, sizeof (dst));\t/* { dg-warning \"call is the same expression as the destination; did you mean to dereference it\" } */\n+  memmove (dst, src, sizeof (dst));\t/* { dg-warning \"call is the same expression as the destination; did you mean to dereference it\" } */\n+  memcpy (dst, src, sizeof (src));\t/* { dg-warning \"call is the same expression as the source; did you mean to dereference it\" } */\n+  memmove (dst, src, sizeof (src));\t/* { dg-warning \"call is the same expression as the source; did you mean to dereference it\" } */\n+}\n+\n+void\n+f2 (struct A *p)\n+{\n+  memset (p, 0, sizeof (p));\t\t/* { dg-warning \"call is the same expression as the destination; did you mean to dereference it\" } */\n+}\n+\n+void\n+f3 (char *dst, const char *src)\n+{\n+  strncpy (dst, src, sizeof (dst));\t/* { dg-warning \"call is the same expression as the destination; did you mean to provide an explicit length\" } */\n+  strncat (dst, src, sizeof (dst));\t/* { dg-warning \"call is the same expression as the destination; did you mean to provide an explicit length\" } */\n+}\n-- \n2.43.0\n\n",
    "prefixes": []
}