mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: Jeff Dike <jdike@karaya.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Daniel Phillips <phillips@bonn-fries.net>,
	"David S. Miller" <davem@redhat.com>,
	tpepper@vato.org, f5ibh@db0bm.ampr.org,
	linux-kernel@vger.kernel.org
Subject: Re: 2.4.9 does not compile [PATCH]
Date: Thu, 16 Aug 2001 18:49:58 -0700	[thread overview]
Message-ID: <3B7C7846.FD9DEE68@zip.com.au> (raw)
In-Reply-To: <200108170146.UAA05171@ccure.karaya.com>, <Your message of "Fri, 17 Aug 2001 00:35:02 +0100." <5.1.0.14.2.20010817002825.00b1e4e0@pop.cus.cam.ac.uk> <5.1.0.14.2.20010817015007.045689b0@pop.cus.cam.ac.uk>

Anton Altaparmakov wrote:
> 
> #define min(x,y) \
>          ({ typeof(x) __x = (x); typeof(y) __y = (y); __x < __y ? __x : __y; })
> 
> int test(int a, int b, int c)
> {
>          return min(a, min(b, c));
> }

Problems occur if the caller happens to pass in variables whose
names confilct with the ones you chose in the above macro:

laptop:/home/akpm> cat t.c
#define min(x,y) \
         ({ typeof(x) __x = (x); typeof(y) __y = (y); __x < __y ? __x : __y; })

int test(int __x, int __y)
{
        return min(__x, __y);		/* sic */
}

main()
{
        printf("%d\n", test(1, 2));
        printf("%d\n", test(2, 1));
}
laptop:/home/akpm> gcc t.c
laptop:/home/akpm> ./a.out
-1073744344
1074305684


So if you replace "__x" with "__dont_use_this_identifier_its_reserved_for_min"
I don't expect anyone could sensibly complain...

-

  reply	other threads:[~2001-08-17  1:56 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-16 21:11 2.4.9 does not compile f5ibh
2001-08-16 21:41 ` 2.4.9 does not compile [PATCH] tpepper
2001-08-16 22:10 ` 2.4.9 does not compile [better PATCH] tpepper
2001-08-16 22:21 ` 2.4.9 does not compile [PATCH] Anton Altaparmakov
2001-08-16 22:28 ` 2.4.9 does not compile [better PATCH] Anton Altaparmakov
2001-08-17  4:23   ` Jeff Chua
2001-08-16 22:31 ` 2.4.9 does not compile [PATCH] David S. Miller
2001-08-16 23:11   ` David S. Miller
2001-08-16 23:13   ` Daniel Phillips
2001-08-16 23:14     ` Alan Cox
2001-08-16 23:40       ` David S. Miller
2001-08-17 21:58         ` David S. Miller
2001-08-16 23:35     ` Anton Altaparmakov
2001-08-17  1:46       ` Jeff Dike
     [not found]         ` <Your message of "Fri, 17 Aug 2001 00:35:02 +0100." <5.1.0.14.2.20010817002825.00b1e4e0@pop.cus.cam.ac.uk>
2001-08-17  1:22           ` Anton Altaparmakov
2001-08-17  1:49             ` Andrew Morton [this message]
2001-08-17  2:05               ` Daniel Phillips
2001-08-17  1:53             ` David S. Miller
2001-08-17  3:55             ` Jeff Dike
2001-08-16 23:38   ` David S. Miller
2001-08-17  1:24     ` Roman Zippel
2001-08-17  1:50     ` David S. Miller
2001-08-17  2:29       ` Roman Zippel
2001-08-17  2:38       ` David S. Miller
2001-08-17  2:53         ` Roman Zippel
2001-08-17  2:59         ` David S. Miller
2001-08-17  3:23           ` Roman Zippel
2001-08-17  3:37           ` David S. Miller
2001-08-17  3:59             ` Roman Zippel
2001-08-17  8:35             ` Anton Altaparmakov
2001-08-17  4:29           ` Ben LaHaise
2001-08-17  6:07           ` David S. Miller
2001-08-17  3:08         ` Roman Zippel
2001-08-17  3:13         ` David S. Miller
2001-08-17  3:39           ` Roman Zippel
2001-08-17  3:44           ` David S. Miller
2001-08-17 17:30   ` Rik van Riel
2001-08-16 23:22 ` Anton Altaparmakov
2001-08-17  1:06 ` 2.4.9 does not compile (adaptec new driver) Luigi Genoni
     [not found] <Your message of "Fri, 17 Aug 2001 00:35:02 +0100."  <5.1.0.14.2.20010817002825.00b1e4e0@pop.cus.cam.ac.uk.suse.lists.linux.kernel>
     [not found] ` <5.1.0.14.2.20010817015007.045689b0@pop.cus.cam.ac.uk.suse.lists.linux.kernel>
     [not found]   ` <3B7C7846.FD9DEE68@zip.com.au.suse.lists.linux.kernel>
     [not found]     ` <20010816.185319.88475216.davem@redhat.com.suse.lists.linux.kernel>
2001-08-17  7:30       ` 2.4.9 does not compile [PATCH] Andi Kleen
     [not found] <no.id>
2001-08-16 22:41 ` Alan Cox
2001-08-16 22:48 ` David S. Miller
2001-08-17 21:12   ` Jes Sorensen
2001-08-16 22:55 ` Alan Cox
2001-08-16 23:02 ` David S. Miller
2001-08-17 21:59   ` David S. Miller
2001-08-16 23:08 ` Alan Cox
2001-08-17  9:11 ` Alan Cox
2001-08-17  9:17 ` Alan Cox
2001-08-17  9:25 ` Alan Cox
2001-08-17 20:57 ` David S. Miller
2001-08-17 21:40 ` Alan Cox
2001-08-17 22:09 ` Alan Cox
2001-08-17 22:11 ` David S. Miller
2001-08-17 23:34   ` Daniel Phillips
2001-08-17 23:38   ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B7C7846.FD9DEE68@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=aia21@cam.ac.uk \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@redhat.com \
    --cc=f5ibh@db0bm.ampr.org \
    --cc=jdike@karaya.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillips@bonn-fries.net \
    --cc=tpepper@vato.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome