public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/28778] [4.0/4.1/4.2 Regression] alias bug with cast and call clobbered
Date: Tue, 26 Sep 2006 14:32:00 -0000	[thread overview]
Message-ID: <20060926143203.14838.qmail@sourceware.org> (raw)
In-Reply-To: <bug-28778-1447@http.gcc.gnu.org/bugzilla/>



------- Comment #36 from pinskia at gcc dot gnu dot org  2006-09-26 14:32 -------

> It's also wrong to assume that unions can be used for type punning, but so
> what? It is allowed by gcc.

No, it is less there as the behavior with unions is unspecified and not
undefined unlike type punning via an address/type cast.


> Evidence: this bug has existed for ages, meanwhile aliasing violations keep
> getting reported as compiler bugs.
This bug (PR28778) has only existed for the last two major releases which is
not ages.

> Since gcc introduced strict aliasing, I've worked at three places doing
> software development. All were embedded/OS related, so I would say the people
> are/were hard-core programmers with a clue. Everybody is shocked when I explain
> strict-aliasing, and all but one have been horrified.

And Aliasing rules in C have existed now for at least 17 years.  It is not like
it magically was added either.  Yes GCC is one of the few compiler that uses
the information produced by type based aliasing anyalsis but that does not mean
GCC is wrong.  Yes GCC turned on "strict" aliasing only 7 years ago but the
aliasing rules have been around for 10 years longer than that.


> So, to get back to this bug specifically: treating a (void*) arg the same as a
> (char*) arg will cover up the problem for nearly everyone. Sadly it won't fix
> the example given, which is legit to a language lawyer and a nonsense piece of
> shit to any normal programmer. Oh well. By treating (void*) the same as
> (char*), you can demote the bug severity greatly and move on.

Again, aliasing in C has to do with accesses and nothing to the type of
pointers.  In fact this is aliasing rules in all languages have to do with
accesses and not the type.  Look at Fortran (which have existed since at least
1977) aliasing rules wich basically say no two arguments alias which makes
people write undefined code easier than with C aliasing.
> 
> BTW, in the testcase, the following line should generate a warning:
> 
> glChoosePixelFormat((GLint*)blist);

Why there is nothing questionable about it until glChoosePixelFormat deferences
the agrument in the wrong type.


-- 


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


  parent reply	other threads:[~2006-09-26 14:32 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-18 21:07 [Bug tree-optimization/28778] New: strict-aliasing bug mrs at apple dot com
2006-08-18 21:11 ` [Bug tree-optimization/28778] " pinskia at gcc dot gnu dot org
2006-08-18 21:12 ` mrs at apple dot com
2006-08-18 21:15 ` pinskia at gcc dot gnu dot org
2006-08-18 21:18 ` [Bug tree-optimization/28778] [4.0/4.1/4.2 Regression] alias bug with cast and call clobbered pinskia at gcc dot gnu dot org
2006-08-19 10:15 ` rguenth at gcc dot gnu dot org
2006-08-19 10:44 ` rguenth at gcc dot gnu dot org
2006-08-19 14:10 ` dberlin at gcc dot gnu dot org
2006-08-19 14:27 ` rguenth at gcc dot gnu dot org
2006-08-20 22:53 ` mmitchel at gcc dot gnu dot org
2006-08-21  1:34 ` dberlin at dberlin dot org
2006-08-21 16:34 ` janis at gcc dot gnu dot org
2006-08-25 19:57 ` drow at gcc dot gnu dot org
2006-08-25 20:51 ` drow at gcc dot gnu dot org
2006-08-25 20:57 ` drow at gcc dot gnu dot org
2006-08-25 22:12 ` drow at gcc dot gnu dot org
2006-08-26 15:15 ` drow at gcc dot gnu dot org
2006-08-26 20:30 ` rguenth at gcc dot gnu dot org
2006-08-26 20:42 ` rguenth at gcc dot gnu dot org
2006-08-26 23:25 ` drow at gcc dot gnu dot org
2006-08-27  4:12 ` dberlin at dberlin dot org
2006-08-27 14:20 ` rguenth at gcc dot gnu dot org
2006-08-27 15:41 ` dberlin at dberlin dot org
2006-08-27 15:50 ` rguenth at gcc dot gnu dot org
2006-08-27 16:00 ` dberlin at dberlin dot org
2006-08-27 17:56 ` drow at gcc dot gnu dot org
2006-08-27 20:25 ` mmitchel at gcc dot gnu dot org
2006-08-27 20:28 ` mmitchel at gcc dot gnu dot org
2006-08-27 20:51 ` dberlin at dberlin dot org
2006-08-27 21:09 ` dberlin at dberlin dot org
2006-08-28  8:43 ` rguenth at gcc dot gnu dot org
2006-09-09 17:55 ` dberlin at dberlin dot org
2006-09-16 18:09 ` steven at gcc dot gnu dot org
2006-09-16 20:03 ` dberlin at dberlin dot org
2006-09-26  4:44 ` acahalan at gmail dot com
2006-09-26  4:56   ` Andrew Pinski
2006-09-26  4:56 ` pinskia at physics dot uc dot edu
2006-09-26 14:17 ` acahalan at gmail dot com
2006-09-26 14:32 ` pinskia at gcc dot gnu dot org [this message]
2006-09-26 15:33 ` acahalan at gmail dot com
2006-09-26 15:47 ` dberlin at dberlin dot org
2006-09-26 15:49 ` pinskia at gcc dot gnu dot org
2006-09-26 15:57 ` pcarlini at suse dot de
2006-09-27  2:12 ` dberlin at dberlin dot org
2006-10-13 17:50 ` dberlin at gcc dot gnu dot org
2006-10-19 23:06 ` dberlin at gcc dot gnu dot org
2006-10-19 23:07 ` dberlin at gcc dot gnu dot org
2006-10-20  8:25 ` [Bug tree-optimization/28778] [4.0/4.1 " rguenth at gcc dot gnu dot org
2006-11-05 22:17 ` chuck at vertica dot com
2006-11-05 22:26 ` drow at gcc dot gnu dot org
2006-11-05 22:26 ` pinskia at gcc dot gnu dot org
2006-11-05 23:39 ` chuck at vertica dot com
2007-01-25 15:51 ` gdr at gcc dot gnu dot org
2007-02-07 22:52 ` pinskia at gcc dot gnu dot org
2007-02-14  9:09 ` mmitchel at gcc dot gnu dot org
2008-07-04 15:51 ` [Bug tree-optimization/28778] [4.1 " jsm28 at gcc dot gnu dot org

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=20060926143203.14838.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).