public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rogerio at rilhas dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/45249] Indirect variable parameters sometimes cause segmentation fault
Date: Wed, 11 Aug 2010 19:51:00 -0000	[thread overview]
Message-ID: <20100811195109.4206.qmail@sourceware.org> (raw)
In-Reply-To: <bug-45249-19547@http.gcc.gnu.org/bugzilla/>



------- Comment #25 from rogerio at rilhas dot com  2010-08-11 19:51 -------
(In reply to comment #24)
> (In reply to comment #22)
> > 
> > If GCC supports cdecl on a x86 plaform then it must support the packing of
> > parameters as defined for x86 (it is not standardize that I know of, but it is
> > well defined). I sugest reading
> > http://en.wikipedia.org/wiki/X86_calling_conventions for a number of references
> > on this parameter packing in the stack, one of my favorites is
> > "http://sco.com./developers/devspecs/abi386-4.pdf" where you can read in
> > "Figure 3-48: C Stack Frame" how the parameters should be placed on the stack.
> That's a good reference. Did you see page 70?
> If you're not interested in writing portable code, don't blame the compiler.
> > Anyway, that enough for me, I already spent way too much energy and time 
> At least we can agree on that.

The reason for the reference of page 70 is exactly because of compilers like
GCC which claim to be cdecl compliant and are not. If GCC would do what it
claims to do and be cdecl compliant I would not blame the compiler and my code
(and code from many others) would be portable.

In other words my code is not portable because GCC is not doing what it should.
GCC causes code not to be portable a lot of times, like in the following case
(which does not compile because of GCC's shortcommings):

class Temp {
public:
Temp(int b);
Temp(Temp& t);
void operator=(Temp& t);
};

void func(int a, class Temp& b, int c);

func(10, Temp(20), 30); // error

This code does not compile in GCC, and so is not portable. That's shortcomming
of GCC that makes my code be not portable, not me. Its GCC's fault that code
that invokes Temp(20) as a parameter is not portable, not the programmer's
fault.

Unfortunately, conversations like this one show that GCC will never be perfect,
because people like you will insist that the compiler doesn't need to do what I
said it should (even when facing the obvious references that I've posted), and
prove that page 70 is right about warning programmers not to rely on compilers
to do correct parameter placements.

My personal experience is that GCC is the cause for such portability problems.
You still insist that GCC doesn't need to improve in this respect, and that
shows why GCC will never be as good as other compilers. Microsoft, for example,
appreciates comments like mine because it helps them improve the product, but
you just want to dismiss it as bad code on my part. I know Microsoft's people
get paid to do so, but, still, I'm talking about the right mind set.

Note that you have not stated why you think my reply #22 is wrong, and I'm
pretty sure that's because you can't. All my arguments are solidly backed up,
but you just looked at page 70, interpreted it incorrectly (because you didn't
realize that compilers like GCC are the ones responsible for that remark), and
didn't bother to see that I'm right about my arguments. You just say that I
can't do it, but I have shown why I should be able to do it. You just dismissed
it, I think is a loss for GCC, but whatever.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45249


  parent reply	other threads:[~2010-08-11 19:51 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-10 21:55 [Bug c++/45249] New: " rogerio at rilhas dot com
2010-08-10 22:03 ` [Bug c++/45249] " rogerio at rilhas dot com
2010-08-10 22:04 ` rogerio at rilhas dot com
2010-08-10 22:04 ` rogerio at rilhas dot com
2010-08-10 22:07 ` pinskia at gcc dot gnu dot org
2010-08-10 22:33 ` rogerio at rilhas dot com
2010-08-10 22:36 ` rogerio at rilhas dot com
2010-08-10 23:08 ` pinskia at gcc dot gnu dot org
2010-08-11  0:55 ` rogerio at rilhas dot com
2010-08-11  0:58 ` pinskia at gcc dot gnu dot org
2010-08-11  1:57 ` rogerio at rilhas dot com
2010-08-11  3:52 ` pinskia at gcc dot gnu dot org
2010-08-11 11:21 ` rogerio at rilhas dot com
2010-08-11 11:21 ` rogerio at rilhas dot com
2010-08-11 11:22 ` rogerio at rilhas dot com
2010-08-11 11:37 ` rguenth at gcc dot gnu dot org
2010-08-11 11:41 ` rguenth at gcc dot gnu dot org
2010-08-11 11:55 ` redi at gcc dot gnu dot org
2010-08-11 13:12 ` rogerio at rilhas dot com
2010-08-11 14:10 ` redi at gcc dot gnu dot org
2010-08-11 16:11 ` matz at gcc dot gnu dot org
2010-08-11 17:04 ` rogerio at rilhas dot com
2010-08-11 17:15 ` rogerio at rilhas dot com
2010-08-11 17:49 ` pinskia at gcc dot gnu dot org
2010-08-11 17:57 ` redi at gcc dot gnu dot org
2010-08-11 19:51 ` rogerio at rilhas dot com [this message]
2010-08-11 19:54 ` pinskia at gcc dot gnu dot org
2010-08-11 20:04 ` rogerio at rilhas dot com
2010-08-11 20:07 ` rogerio at rilhas dot com
2010-08-11 20:33 ` rguenth at gcc dot gnu dot org
2010-08-11 20:58 ` rogerio at rilhas dot com
2010-08-11 21:02 ` pinskia at gcc dot gnu dot org
2010-08-11 21:12 ` rogerio at rilhas dot com
2010-08-11 21:16 ` pinskia at gcc dot gnu dot org
2010-08-11 21:27 ` redi at gcc dot gnu dot org
2010-08-11 22:17 ` rogerio at rilhas dot com
2010-08-11 22:27 ` rguenth at gcc dot gnu dot org
2010-08-11 22:31 ` rguenth at gcc dot gnu dot org
2010-08-11 22:35 ` rogerio at rilhas dot com
2010-08-11 22:37 ` rogerio at rilhas dot com
2010-08-11 22:48 ` rguenth at gcc dot gnu dot org
2010-08-11 22:50 ` rogerio at rilhas dot com
2010-08-11 22:51 ` rogerio at rilhas dot com
2010-08-11 22:52 ` rogerio at rilhas dot com
2010-08-11 22:53 ` rogerio at rilhas dot com
2010-08-11 22:54 ` rogerio at rilhas dot com
2010-08-11 22:54 ` rogerio at rilhas dot com
2010-08-11 22:55 ` rogerio at rilhas dot com
2010-08-11 22:58 ` pinskia at gcc dot gnu dot org
2010-08-11 23:22 ` rogerio at rilhas dot com
2010-08-11 23:43 ` rogerio at rilhas dot com
2010-08-12  2:08 ` rogerio at rilhas dot com
2010-08-12  2:10 ` rogerio at rilhas dot com
2010-08-12  2:11 ` rogerio at rilhas dot com
2010-08-12  2:12 ` rogerio at rilhas dot com
2010-08-12  2:13 ` rogerio at rilhas dot com
2010-08-12  8:20 ` jakub at gcc dot gnu dot org
2010-08-12 10:17 ` rogerio at rilhas dot com
2010-08-12 10:18 ` paolo dot carlini at oracle dot com

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=20100811195109.4206.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).