public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect
@ 2005-05-12 10:53 alexander_herrmann at yahoo dot com dot au
2005-05-12 12:13 ` [Bug tree-optimization/21531] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-12 10:53 UTC (permalink / raw)
To: gcc-bugs
GNU C - maybe related to my bugreport 21513 but different.
Error:
src/aie_sql_meta.c: In Funktion aie_sql_meta_create_index:
src/aie_sql_meta.c:258: Warnung: tableid koennte in dieser Funktion
uninitialisiert verwendet werden
src/aie_sql_meta.c:259: Warnung: index_typ koennte in dieser Funktion
uninitialisiert verwendet werden
make: *** [obj/aie_sql_meta.o] Fehler 1
int tableid;
int index_typ;
could be unitilized in this function. It can but if not it's not used.
Difference to GCC 3.4.3. It is set but within another function. The function
itself resides in the same sourcefile so imo gcc would be able to figure out
that they are either initilized or not used. Especially when compiled with the
compiler switch -funit-at-a-time . btw if the initialisation would be in another
C sourcefile then the warning is ok imo because the compiler cannot know the
content - as tody - of two sourcefiles at the same time.
The function is to create a SQL Index out of a predefined structure. The two
variables are set within the function aie_sql_meta_get_index_def_from_id - see
below.
The function it is as follows:
bool aie_sql_meta_create_index(int indexid, struct aie_sql_meta_db
*aie_sql_meta_db)
{
bool rc = true;
const char *index_name = aie_sql_meta_get_index_name_from_id(indexid,
aie_sql_meta_db);
if (__builtin_expect((index_name != NULL),true))
{
unsigned int size_index_def = 0;
int tableid;
int index_typ;
struct aie_sql_index_def *index_def =
aie_sql_meta_get_index_def_from_id(indexid, &tableid, &index_typ,
&size_index_def,
aie_sql_meta_db);
if (__builtin_expect(((index_def == NULL) ||
(size_index_def <= 0) ||
(tableid <= 0)),false))
{
sys_log("%s(%d):Fehler Meta SQL Table Def Create index "
"IndexID[%d] index [%s] TableID[%d]!",
__FILE__,
__LINE__,
indexid,
index_name,
tableid);
rc = false;
}
else
{
const char *table_name = aie_sql_meta_get_table_name_from_id(tableid,
aie_sql_meta_db);
if (__builtin_expect((table_name != NULL),true))
{
if (__builtin_expect(
(!aie_sql_create_index(aie_sql_meta_db->aie_sql_data,
table_name,
index_name,
index_typ,
true,
index_def,
size_index_def)),false))
{
sys_log("%s(%d):Fehler Meta SQL Create index "
"IndexID[%d] index [%s] Tableid[%d]!",
__FILE__,
__LINE__,
indexid,
index_name,
tableid);
rc = false;
}
}
else
{
sys_log("%s(%d):Fehler Meta SQL Create index Table nicht gefunden "
"IndexID[%d] index [%s] Tableid[%d]!",
__FILE__,
__LINE__,
indexid,
index_name,
tableid);
rc = false;
}
}
}
else
{
sys_log("%s(%d): Create Table ID[%d] Table ID nicht gefunden!",
__FILE__,
__LINE__,
indexid);
rc = false;
}
return(rc);
}
struct aie_sql_index_def *aie_sql_meta_get_index_def_from_id(int indexid,
int *tableid,
int *index_typ,
unsigned int *size_index_def,
struct aie_sql_meta_db
*aie_sql_meta_db)
{
struct aie_sql_index_def *aie_index_def = NULL;
if (__builtin_expect((aie_sql_meta_db != NULL), true))
{
struct aie_sql_db *sql_db = aie_sql_meta_db->sql_db;
unsigned int size_sql_db = aie_sql_meta_db->size_sql_db;
if (__builtin_expect(((sql_db != NULL) && (size_sql_db > 0)), true))
{
register unsigned int z = 0;
for(z = 0;z < size_sql_db;z++)
{
struct aie_sql_index *tbl_index;
if (__builtin_expect(((tbl_index = sql_db->index) != NULL),true))
{
unsigned int size_index = sql_db->size_index;
if (__builtin_expect((size_index > 0),true))
{
register unsigned int y = 0;
for(y = 0; y < size_index; y++)
{
if (__builtin_expect((tbl_index->indexid == indexid),
false))
{
if (__builtin_expect((tableid != NULL),true))
{
*tableid = tbl_index->tableid;
}
if (__builtin_expect((index_typ != NULL),true))
{
*index_typ = tbl_index->index_typ;
}
if (__builtin_expect((size_index_def != NULL),true))
{
*size_index_def = tbl_index->size_index_def;
}
aie_index_def = tbl_index->index_def;
break;
}
tbl_index++;
}
}
else
{
sys_log("%s(%d): Warnung DB %d Indizies == 0", __FILE__,
__LINE__,
sql_db->dbid);
}
}
else
{
//sys_log("%s(%d): Warnung DB %d keine Indizies!", __FILE__,
// __LINE__,
// sql_db->dbid);
}
sql_db++;
}
}
else
{
sys_log("%s(%d): Mata Date - Keine DB Info", __FILE__, __LINE__);
}
}
else
{
sys_log("%s(%d): Mata Date Ptr == NULL!", __FILE__, __LINE__);
}
return(aie_index_def);
}
Solution: Waste a byte and maybe a CPU cycle and initilize it when defined.
--
Summary: 4.0/4.1 Regression __builtin_expect
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alexander_herrmann at yahoo dot com dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
@ 2005-05-12 12:13 ` pinskia at gcc dot gnu dot org
2005-05-13 9:53 ` alexander_herrmann at yahoo dot com dot au
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-12 12:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-12 12:12 -------
Can you attached the preprocessed source code (The only reason why I did not ask for PR 21513 is
because I figured out to compile it and reproduce it without it).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
2005-05-12 12:13 ` [Bug tree-optimization/21531] " pinskia at gcc dot gnu dot org
@ 2005-05-13 9:53 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 11:17 ` alexander_herrmann at yahoo dot com dot au
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-13 9:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From alexander_herrmann at yahoo dot com dot au 2005-05-13 09:53 -------
Subject: Re: 4.0/4.1 Regression __builtin_expect
Hi there,
> ------- Additional Comments From pinskia at gcc dot
> gnu dot org 2005-05-12 12:12 -------
> Can you attached the preprocessed source code (The
> only reason why I did not ask for PR 21513 is
> because I figured out to compile it and reproduce it
> without it).
Ok, I will do so. I also make a testcase for it - till
tommorow. Sorry for the delay but I have some paid
work higher in my priority.
Alexander
____________________________________________________________
http://vendian.aiengine.org - Artificial Life for your CPU
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
2005-05-12 12:13 ` [Bug tree-optimization/21531] " pinskia at gcc dot gnu dot org
2005-05-13 9:53 ` alexander_herrmann at yahoo dot com dot au
@ 2005-05-13 11:17 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 11:42 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-13 11:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From alexander_herrmann at yahoo dot com dot au 2005-05-13 11:16 -------
Subject: Re: 4.0/4.1 Regression __builtin_expect
The promised Testcase. Earlier than expected :)
aie_sql_meta.c: In Funktion
ปaie_sql_meta_create_indexซ:
aie_sql_meta.c:32: Warnung: ปindex_typซ
k๖nnte in dieser Funktion uninitialisiert
verwendet werden
aie_sql_meta.c:31: Warnung: ปtableidซ
k๖nnte in dieser Funktion uninitialisiert
verwendet werden
It only seems to happen with the compilerswitches
-Wall -O3
It's kinda complete program so I guess the (very
large) precompiled isn't needed. Thanks for the fast
response and btw. GCC 4.0.0 seems to be a good work.
Finds more undefined prototypes than 3.4.3. What is
kind of missing is a error and a warning number as the
messages may be in strange languages these days which
makes it hard for english only to figure out what the
message means. Just a suggestion which came to my mind
producing the testcase. Maybe I should work on that :)
in my spare time.
#include <stdlib.h>
#include <stdio.h>
// reduced Testcase
// compiled with
// gcc -Wall -O3 aie_sql_meta.c
// Alexander J. Herrmann 13.05.2005
webmaster@aiengine.org
typedef int bool;
struct aie_sql_index_def
{
char *something;
};
bool aie_sql_meta_create_index(int indexid);
struct aie_sql_index_def
*aie_sql_meta_get_index_def_from_id(int indexid,
int *tableid,
int *index_typ);
int main(void)
{
aie_sql_meta_create_index(1); // the good case
aie_sql_meta_create_index(0); // the never should
happen case
return(0);
}
bool aie_sql_meta_create_index(int indexid)
{
bool rc = 1;
int tableid; // These are the two variables
complained about
int index_typ;
struct aie_sql_index_def *index_def =
aie_sql_meta_get_index_def_from_id(indexid,
&tableid, &index_typ);
if (__builtin_expect(((index_def == NULL) ||
(tableid <= 0)),0))
{
// error variables not set but also not used
rc = 0;
}
else
{
// Ok, variables set and used
printf("%d %d\n", tableid, index_typ);
}
return(rc);
}
struct aie_sql_index_def
*aie_sql_meta_get_index_def_from_id(int indexid,
int *tableid,
int *index_typ)
{
static struct aie_sql_index_def aie_index_def;
if (indexid == 1)
{
// the Good case
*tableid = 1;
*index_typ = 1;
}
else
{
// The what never should happen case
return(NULL);
}
return(&aie_index_def);
}
____________________________________________________________
http://vendian.aiengine.org - Artificial Life for your CPU
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
` (2 preceding siblings ...)
2005-05-13 11:17 ` alexander_herrmann at yahoo dot com dot au
@ 2005-05-13 11:42 ` pinskia at gcc dot gnu dot org
2005-05-13 11:55 ` alexander_herrmann at yahoo dot com dot au
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-13 11:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-13 11:42 -------
The warning is correct for tableid and index_typ as this is an "or" expression.
So this is invalid.
If I change it to && then that is just PR 21513.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
` (3 preceding siblings ...)
2005-05-13 11:42 ` pinskia at gcc dot gnu dot org
@ 2005-05-13 11:55 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 12:00 ` pinskia at gcc dot gnu dot org
2005-05-13 13:07 ` alexander_herrmann at yahoo dot com dot au
6 siblings, 0 replies; 8+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-13 11:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From alexander_herrmann at yahoo dot com dot au 2005-05-13 11:55 -------
Subject: Re: 4.0/4.1 Regression __builtin_expect
> The warning is correct for tableid and index_typ as
> this is an "or" expression.
if (__builtin_expect(((index_def == NULL) ||
(tableid <= 0)),0))
I didn't look at it this way. True but on the other
hand to my knowledge the || for tableid should only be
used when index_def is != NULL and if this is the case
then tableid has been set.
____________________________________________________________
http://vendian.aiengine.org - Artificial Life for your CPU
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
` (4 preceding siblings ...)
2005-05-13 11:55 ` alexander_herrmann at yahoo dot com dot au
@ 2005-05-13 12:00 ` pinskia at gcc dot gnu dot org
2005-05-13 13:07 ` alexander_herrmann at yahoo dot com dot au
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-13 12:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-13 12:00 -------
Then it is a dup of bug 21513.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/21531] 4.0/4.1 Regression __builtin_expect
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
` (5 preceding siblings ...)
2005-05-13 12:00 ` pinskia at gcc dot gnu dot org
@ 2005-05-13 13:07 ` alexander_herrmann at yahoo dot com dot au
6 siblings, 0 replies; 8+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-13 13:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From alexander_herrmann at yahoo dot com dot au 2005-05-13 13:06 -------
Subject: Re: 4.0/4.1 Regression __builtin_expect
Ok, than we move it into another catagory. Compiler
crashes with segmentation fault.
After 20 years of C programing it is like felling
feeling a bug. Trying to produce a testcase with || I
seem to have triggered it. The compiler get's a
segmentation fault on this one :)
aie_sql_meta.c: In Funktion aie_sql_meta_create_index:
aie_sql_meta.c:23: interner Compiler-Fehler:
Segmentation fault
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
// reduced Testcase
// compiled with
// gcc -Wall -O3 aie_sql_meta.c
// Alexander J. Herrmann 13.05.2005
webmaster@aiengine.org
typedef int bool;
bool aie_sql_meta_create_index(void);
void aie_sql_meta_get_index_def_from_id(int indexid,
int *tableid,
int *index_typ);
int main(void)
{
aie_sql_meta_create_index();
return(0);
}
bool aie_sql_meta_create_index(void)
{
bool rc = 1;
int tableid; // Never gets initialized
int index_typ = 1;
int indexid = 0;
aie_sql_meta_get_index_def_from_id(indexid,
&tableid, &index_typ);
if (__builtin_expect(((index_typ) || (tableid <=
0)),0))
{
// error variables not set but also not used
rc = 0;
}
else
{
// tableid was never initialized
printf("%d %d\n", tableid, index_typ);
}
return(rc);
}
void aie_sql_meta_get_index_def_from_id(int indexid,
int *tableid,
int *index_typ)
{
if (indexid == 1)
{
// the Good case
*tableid = 1;
*index_typ = 0;
}
else
{
*index_typ = 0;
}
}
____________________________________________________________
http://vendian.aiengine.org - Artificial Life for your CPU
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21531
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-05-13 13:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-12 10:53 [Bug tree-optimization/21531] New: 4.0/4.1 Regression __builtin_expect alexander_herrmann at yahoo dot com dot au
2005-05-12 12:13 ` [Bug tree-optimization/21531] " pinskia at gcc dot gnu dot org
2005-05-13 9:53 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 11:17 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 11:42 ` pinskia at gcc dot gnu dot org
2005-05-13 11:55 ` alexander_herrmann at yahoo dot com dot au
2005-05-13 12:00 ` pinskia at gcc dot gnu dot org
2005-05-13 13:07 ` alexander_herrmann at yahoo dot com dot au
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).