Thread: An interesting and strange (in my opinion) expression.

  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    1,069

    An interesting and strange (in my opinion) expression.

    I was amazed to learn that this works:

    Code:
    (int){ 0 } = 1;
    Last edited by flp1969; 02-09-2021 at 07:12 AM.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,565
    Code:
    int main()
    {
        // Create temporary struct and assign to it.
        typedef struct { int a; } x;
        (x){0} = (x){1};
     
        // Also works for an int.
        (int){0} = 1;
    }
    Is it just an anomaly? I can't see a use for it. Where did you see it?
    Ordinary language is totally unsuited for expressing what physics really asserts.
    Only mathematics can say as little as the physicist means to say. - Bertrand Russell

  3. #3
    Registered User
    Join Date
    Feb 2019
    Posts
    1,069
    Quote Originally Posted by john.c View Post
    Is it just an anomaly? I can't see a use for it. Where did you see it?
    Not an anomaly... Someone shown me this and I got directly to ISO standard (C99) and it is there... It's a valid expression.
    Does nothing really (except create that annonymous automatic object) -- which is the same to say it does nothing at all.

    I think this is very strange!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange expression
    By SCRIPT_KITTEH in forum C Programming
    Replies: 2
    Last Post: 07-30-2013, 02:50 PM
  2. What is your opinion?
    By Inkinsarto in forum Tech Board
    Replies: 8
    Last Post: 05-03-2013, 07:27 AM
  3. initializer expression list treated as compound expression
    By karthikeyanvisu in forum C Programming
    Replies: 7
    Last Post: 02-26-2011, 05:19 PM
  4. Replies: 2
    Last Post: 11-25-2009, 07:38 AM
  5. Opinion please.
    By Carp in forum Tech Board
    Replies: 4
    Last Post: 02-18-2003, 06:48 PM

Tags for this Thread