From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118019 invoked by alias); 15 Sep 2015 10:28:31 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 117977 invoked by uid 48); 15 Sep 2015 10:28:27 -0000 From: "vegard.nossum at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67582] typeof(*p) * fails when p is void * Date: Tue, 15 Sep 2015 10:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vegard.nossum at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg01214.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67582 --- Comment #3 from Vegard Nossum --- (In reply to Jonathan Wakely from comment #1) > You can't dereference a void*, so why do you expect to be able to get the > type of an invalid expression? I was under the impression that the expression was not actually evaluated, but that only the *type* of the expression was evaluated. For example, I would also expect this to work even though x has not been initialised (which should otherwise be UB when dereferenced): int *x; typeof(*x) y; Similarly, I would also expect the usual #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) to return 0 when passed a zero-length array. Or is that invalid too?