public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics
@ 2005-02-15 13:29 jsm28 at gcc dot gnu dot org
  2005-02-15 14:14 ` [Bug middle-end/19967] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2005-02-15 13:29 UTC (permalink / raw)
  To: gcc-bugs

The folding of built-in functions does not always yield results with
the correct return type, causing excess warnings (errors with -pedantic-errors).

char *strchr(const char *, int);
char *strrchr(const char *, int);
char *index(const char *, int);
char *rindex(const char *, int);
char *strpbrk(const char *, const char *);
char *strstr(const char *, const char *);
char *p;
void
f (void)
{
  p = strchr(__func__, 'f');
  p = strrchr(__func__, 'f');
  p = index(__func__, 'f');
  p = rindex(__func__, 'f');
  p = strpbrk(__func__, "f");
  p = strstr(__func__, "f");
}

should compile with no diagnostics, but instead each assignment
has "assignment discards qualifiers from pointer target type"
because optimizing the built-in function has wrongly changed the
return type to "const char *" instead of "char *".  This is a regression
in 4.0.

-- 
           Summary: built-in folding causes excess diagnostics
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, diagnostic
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
@ 2005-02-15 14:14 ` pinskia at gcc dot gnu dot org
  2005-02-15 15:46 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-15 14:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-15 01:30 -------
: Search converges between 2004-09-15-014001-trunk (#540) and 2004-09-15-161001-trunk 
(#541).

Confirmed.

Caused by:
2004-09-15  Jakub Jelinek  <jakub@redhat.com>

        * expr.c (string_constant): Handle also read-only variables
        initialized to string literals.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com
             Status|UNCONFIRMED                 |NEW
          Component|tree-optimization           |middle-end
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-15 01:30:06
               date|                            |
            Summary|built-in folding causes     |[4.0 Regression] built-in
                   |excess diagnostics          |folding causes excess
                   |                            |diagnostics


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
  2005-02-15 14:14 ` [Bug middle-end/19967] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-02-15 15:46 ` pinskia at gcc dot gnu dot org
  2005-02-15 15:50 ` joseph at codesourcery dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-15 15:46 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
  2005-02-15 14:14 ` [Bug middle-end/19967] [4.0 Regression] " pinskia at gcc dot gnu dot org
  2005-02-15 15:46 ` pinskia at gcc dot gnu dot org
@ 2005-02-15 15:50 ` joseph at codesourcery dot com
  2005-02-15 15:54 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: joseph at codesourcery dot com @ 2005-02-15 15:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2005-02-15 01:37 -------
Subject: Re:  [4.0 Regression] built-in folding causes
 excess diagnostics

On Tue, 15 Feb 2005, pinskia at gcc dot gnu dot org wrote:

> Caused by:
> 2004-09-15  Jakub Jelinek  <jakub@redhat.com>
> 
>         * expr.c (string_constant): Handle also read-only variables
>         initialized to string literals.

I'm not sure how useful it is to treat that patch as the cause.  I used 
__func__ to keep the example within ISO C (apart from the cases of the 
non-standard functions index and rindex).  You can get the same effect 
with "f" in place of __func__ and -Wwrite-strings (though the constant is 
const char * with -Wwrite-strings, these standard functions remove 
constness found in their argument in C).  I suspect you'll find a 
different causing patch for

char *strchr(const char *, int);
char *strrchr(const char *, int);
char *index(const char *, int);
char *rindex(const char *, int);
char *strpbrk(const char *, const char *);
char *strstr(const char *, const char *);
char *p;
void
f (void)
{
  p = strchr("f", 'f');
  p = strrchr("f", 'f');
  p = index("f", 'f');
  p = rindex("f", 'f');
  p = strpbrk("f", "f");
  p = strstr("f", "f");
}

with -Wwrite-strings, although the underlying bug is the same.



-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-02-15 15:50 ` joseph at codesourcery dot com
@ 2005-02-15 15:54 ` pinskia at gcc dot gnu dot org
  2005-02-15 17:24 ` kazu at cs dot umass dot edu
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-15 15:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-15 01:46 -------
(In reply to comment #2)
Yes I do (depending on which function by the way):
: Search converges between 2004-05-23-trunk (#458) and 2004-06-01-trunk (#459).
2004-05-30  Steven Bosscher  <stevenb@suse.de>

        PR tree-optimization/14819
        * builtins.c (fold_builtin_strchr): New.
        (fold_builtin_1): Handle BUILT_IN_STRCHR and BUILT_IN_STRRCHR
        with fold_builtin_strchr().
2004-05-31  Kazu Hirata  <kazu@cs.umass.edu>

        PR tree-optimization/15743.
        * builtins.c (fold_builtin_1): Fold index() and rindex().


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kazu at cs dot umass dot
                   |                            |edu, stevenb at suse dot de


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-02-15 15:54 ` pinskia at gcc dot gnu dot org
@ 2005-02-15 17:24 ` kazu at cs dot umass dot edu
  2005-02-16  7:01 ` [Bug tree-optimization/19967] " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-15 17:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-02-15 04:44 -------
I've got a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |kazu at cs dot umass dot edu
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-02-15 17:24 ` kazu at cs dot umass dot edu
@ 2005-02-16  7:01 ` pinskia at gcc dot gnu dot org
  2005-02-16 19:32 ` cvs-commit at gcc dot gnu dot org
  2005-02-16 19:35 ` kazu at cs dot umass dot edu
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-16  7:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-16 02:05 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00894.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2005-02-16  7:01 ` [Bug tree-optimization/19967] " pinskia at gcc dot gnu dot org
@ 2005-02-16 19:32 ` cvs-commit at gcc dot gnu dot org
  2005-02-16 19:35 ` kazu at cs dot umass dot edu
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-16 19:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-16 15:39 -------
Subject: Bug 19967

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kazu@gcc.gnu.org	2005-02-16 15:39:31

Modified files:
	gcc            : ChangeLog builtins.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr19967.c 

Log message:
	PR tree-optimization/19967
	* builtins.c (expand_builtin_strstr, expand_builtin_strpbrk,
	expand_builtin_strchr, expand_builtin_strrchr): Take a new
	argument TYPE.  Adjust calls to fold_builtin_XXX.
	(expand_builtin, fold_builtin_1): Adjust calls to
	expand_builtin_XXX.
	(fold_builtin_strchr, fold_builtin_strpbrk,
	fold_builtin_strstr, fold_builtin_strrchr): Convert the folded
	result to a requested type TYPE.
	
	* testsuite/gcc.dg/pr19967.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7493&r2=2.7494
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.422&r2=1.423
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5040&r2=1.5041
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr19967.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug tree-optimization/19967] [4.0 Regression] built-in folding causes excess diagnostics
  2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-02-16 19:32 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-16 19:35 ` kazu at cs dot umass dot edu
  7 siblings, 0 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-16 19:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2005-02-16 15:41 -------
Fixed.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-02-16 15:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-15 13:29 [Bug tree-optimization/19967] New: built-in folding causes excess diagnostics jsm28 at gcc dot gnu dot org
2005-02-15 14:14 ` [Bug middle-end/19967] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-15 15:46 ` pinskia at gcc dot gnu dot org
2005-02-15 15:50 ` joseph at codesourcery dot com
2005-02-15 15:54 ` pinskia at gcc dot gnu dot org
2005-02-15 17:24 ` kazu at cs dot umass dot edu
2005-02-16  7:01 ` [Bug tree-optimization/19967] " pinskia at gcc dot gnu dot org
2005-02-16 19:32 ` cvs-commit at gcc dot gnu dot org
2005-02-16 19:35 ` kazu at cs dot umass dot edu

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