From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id A3936385842D for ; Sat, 30 Mar 2024 09:05:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3936385842D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A3936385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711789613; cv=none; b=XC2Tw6IS7lEQbk5czAXIc8j1yPcG2y+rTtuRAt3QZ5I6vPMmw8V+thkWYeCYrIF0vEcgasm2OXaw3nL6utHgxIM1rqUvHHTvfYmppM0Wg5m1lEV0PjGMreI/V1Q9U4MUeMZuuxpc+v3DosWWpxb+1WejtCqwUZ1IGXHCdDax6pA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711789613; c=relaxed/simple; bh=yAktnQc4tzWWUjsWJ4K9ggTuIAvUhjhzRFLSWZQQVvc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=FtT83qgIik3I5AeKoKqAFpHk63Tl0q0DBt3RQOolr+BxUfpZRrKWDbeG5XptCITEvIhYTr48Jn9KbFYP4TNc7izdOt739Tb8wG4PZjVmKHLv9n9oyVpeJi6fwHE0lry/xUfRY5IpbYKbDDom+bbMVZ7/NSAPAMjNpVN7rTpBDZo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a467d8efe78so325178566b.3 for ; Sat, 30 Mar 2024 02:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711789535; x=1712394335; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PPw49PmNZWy0A5+3FIn4NnuzxqmrFRgmrZCzHLBmWjw=; b=S/4KpeSsLooymKUknQ08/h698jAKsVVsjidPKeShwCw5LnQCafIUD+1AB2qsWSa54y xUoAOzkZtcbC02pd89YfrjYCDDEfLUmULr5vglZQRl3aNYiZ23Z09n/K+n+MdH+ty1ij Km/BEBh83Z7wXtO8T87k55OSPWrUhPXxwUPp2GYvbHk9tFp8ov4sTQULXHZJPAZfzwZ/ fYv/hDVLnBAlhGnpEYDNZ/kixrX8VwajVNCx4cc4BIND/t2K3XEr7CWgWQSS5yTylril ScOp/Eqk1dv5zO58bYys+RYDTp399HmRNnUyhbYzlBb3XddzMZ+2na5ajgyqwn2KWGfL dI0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711789535; x=1712394335; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PPw49PmNZWy0A5+3FIn4NnuzxqmrFRgmrZCzHLBmWjw=; b=ArzjL/4Rz02YvURZyJ2kwBOAaIpgwIqbUpLYps8KHkLwhODTkIY9hX6MgRc2JL8P2/ H07lI4bOE2xnAeIPjayezfAvG82gCwF6tzNAgSuB3rwW6N2FZWy+m0UYgu3gQlSfTMY1 jUa9TwUzHJTK9yBxFQOKFzSyci/2p55ookmK0kBXh5IUR45laHtyWW8u/taBogV11DFu 6hfmi8VpReUO9I/a2exaWgywgPiOmWSe/7cnDuYqYuYNp7BdD46f3xq8LLy50XsQGwFX 0u/hgObZ9gmo3uz8CoMeFsB8xX026hIBlQdLOC6lakPf3XwQD2+xr82Xpstagin8CYxi n2Tw== X-Gm-Message-State: AOJu0YyYS26BSFwdCh1R8CzkEwKxYjs3TzsKIOjs5m9Zcvb5AK+eV9Wj RMfZfTDpo84Sl41px7I4LhNYxmlBtkaGIia5uVqFkaXVHyA3GTTfG9wa4U4/lB7nN8NO31/i+vQ +5+mmohcs7pV/3WFuSsFGyVBHYGk= X-Google-Smtp-Source: AGHT+IHBTOxicchQ1wKJcolKYiceNje0yWSEkeEKoFYV09qGj9j7Wb1wWctcwlRTO9no5BUrxaHXA3N4G28kVa3pN/0= X-Received: by 2002:a17:907:94c5:b0:a4e:226a:cda2 with SMTP id dn5-20020a17090794c500b00a4e226acda2mr4207301ejc.60.1711789534474; Sat, 30 Mar 2024 02:05:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Sat, 30 Mar 2024 09:05:23 +0000 Message-ID: Subject: Re: g++ with VLA To: NightStrike Cc: gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, 30 Mar 2024 at 06:12, NightStrike via Gcc-help wrote: > > https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html > > That doc states that VLAs are supported in C++ as an extension. > Compiling the following: > > void f(int a, int b[a]); > void f() { > int c[2]; > f(2, c); > } > > with g++ -std=gnu++20 results in the error: "use of parameter outside > function body before ']' token". The docs say nothing about partial > support of VLA, just that they can be used. I don't think GNU C++ has any changes to the function declarator syntax to support variably modified types. You can define a VLA object, but you can't use earlier function parameters later in the function-parameter-list, and you can't use int b[*] in a parameter either. > > Where this is useful as an extension is in the somewhat reasonable > case of including a C header in a C++ program. If that C header > declares a function using a C99 VLA, it would be awesome if g++ were > to accept it in -std=gnu++ mode (and it would be fine if it were > rejected in -std=c++ mode). Consider a situation where you cannot > modify the header, and so have to use it as-is. > > Is there perhaps another option to achieve the intended behavior? > > If it's not possible, can this be added? > > If the consensus is that it shouldn't be added, could the docs at > least clarify what is supported and what is not in C++?