Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8239833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:16:49+00:00 2026-06-07T20:16:49+00:00

In GNUC C, you can use typeof(expression) , and it is legal to use

  • 0

In GNUC C, you can use typeof(expression), and it is legal to use an expression with side effects inside. So for example you can have this C code:

int x = 0;
typeof(x++) y;

In this case, the side effect is ignored and x is still zero afterwards (this makes sense as types are a compile-time-only thing).

However, the GCC documentation says:

The operand of typeof is evaluated for its side effects
if and only if it is an expression of variably modified type
or the name of such a type.

What does this sentence mean? Is it really possible to write typeof with a side effect and have the side effect actually be executed at runtime? For me, this sentence seems to indicate this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:16:51+00:00Added an answer on June 7, 2026 at 8:16 pm

    Yes, it is possible in certain cases to have side-effects inside typeof evaluated. As the documentation says, it needs to be within a “variably modified type”. This is a type which depends on some runtime value, such as int[x].

    So the following code is legal, declares y to be of type int[1], and x has the value 1 afterwards:

    int x = 0;
    typeof(int[++x]) y;
    

    Of course, equally to variably modified types in general, this is only legal for local variable declarations (inside function).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use this code to allocate a slice of code to
How can I use configure and make tools to specify to use 64 bit
I have the following code : #define LIMIT_DATE \01-03-2010\ #ifdef LIMIT_DATE #if _MSC_VER #pragma
this code works completely fine in my pc while i compile it with codeblocks
I've got a small bit of code from a library that does this: #define
Is there a way we can query iptables programmatically without making use of shell
I am likely missing something simple but I can't really figure it out. This
I have been dealing with Nasm and GNU C inline asm on a Linux
I am reading source code of hoard memory allocator, and in the file of
When I try to use boost on an old Linux system, I get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.