From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id N4GWMi3+d2JNHgUAWB0awg (envelope-from ) for ; Sun, 08 May 2022 13:30:21 -0400 Received: by simark.ca (Postfix, from userid 112) id C3D2F1E21F; Sun, 8 May 2022 13:30:21 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=J/S7IIuW; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 68B001E143 for ; Sun, 8 May 2022 13:30:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CBD64385734A for ; Sun, 8 May 2022 17:30:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBD64385734A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652031020; bh=bG0QWHRHFsxz2Vkq88PSNRhAq1ryJ4KNMvQ8eaPO8+Q=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=J/S7IIuWBjGNbTRR58yIckqf8CpC1gcKyKtG2n+uB4dQsISgcpiGj3QS+dkSOuOdV BOphltZe/cezSP1nrCIhgDSk6b7X2SpZRMMD1Ve1EZBwL3SOGuzu+eSn6j7UWUl88T V1nOIkMXG9InBiyRoQF7zfH7ILVLAqGpk/NMdWu0= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 21C993858405 for ; Sun, 8 May 2022 17:29:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21C993858405 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id CAB341E143; Sun, 8 May 2022 13:29:50 -0400 (EDT) Message-ID: <89fec0c3-8259-4951-5478-2afe6e0f1643@simark.ca> Date: Sun, 8 May 2022 13:29:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: sizeof Content-Language: en-US To: Russell Shaw , GDB mailing list References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb Reply-To: Simon Marchi Errors-To: gdb-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb" On 2022-05-08 11:22, Russell Shaw wrote: > When inspecting a C++ file, i get: > > (gdb) p sizeof(int()) > $82 = 1 > > (gdb) p sizeof(int) > $83 = 4 > > Not right ? > > Package: gdb > Version: 11.2-1 > on debian The compiler seems to agree with GDB: $ cat test.cpp #include int main() { printf("%zu\n", sizeof(int)); printf("%zu\n", sizeof(int())); } $ g++ test.cpp test.cpp: In function ‘int main()’: test.cpp:6:19: warning: invalid application of ‘sizeof’ to a function type [-Wpointer-arith] 6 | printf("%zu\n", sizeof(int())); | ^~~~~~~~~~~~~ $ ./a.out 4 1 I don't really know what sizeof(int()) means anyway. clang just rejects it: $ clang++ test.cpp test.cpp:6:19: error: invalid application of 'sizeof' to a function type printf("%zu\n", sizeof(int())); ^ ~~~~~~~ Simon