This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/7710: GCC warns "<var> might be used uninitialized" when optimisation turned on


>Number:         7710
>Category:       c
>Synopsis:       GCC warns "<var> might be used uninitialized" when optimisation turned on
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 24 05:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     royhills@hotmail.com
>Release:        GCC 2.95.2
>Organization:
>Environment:
Debian Linux "Potato" (2.2r7) running on i386 with custom 2.2.19 Kernel.
>Description:
GCC 2.95.2 on Debian Linux 2.2r7 gives the warning:
"`fp' might be used uninitialized in this function"
when optimisation is turned on with -O1 or -O2, but no
warning is issued if optimisation is turned off.

I've simplified the code to a 13 line program which I attach to this bug report.  Lookig at the code, I can see no way that the variable "fp" could be used uninitialised.

This issue doesn't seem to affect the real program which works fine with -O2 (so far anyway...).

Example:

# Program compiles fine without optimisation
rsh@roy:/usr/home/rsh/src$ gcc -Wall gcc-fp-unused.c

# But it gives the warning with optimisation on
rsh@roy:/usr/home/rsh/src$ gcc -O2 -Wall gcc-fp-unused.c
gcc-fp-unused.c: In function `main':
gcc-fp-unused.c:6: warning: `fp' might be used uninitialized in this function
>How-To-Repeat:
Bug is fully repeatable on my system.  Warning occurs every time the file shown in the attachment is compiled with optimisation turned on.
>Fix:
Compile without optimisation :-)
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gcc-fp-unused.ts"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gcc-fp-unused.ts"

U2NyaXB0IHN0YXJ0ZWQgb24gRnJpIEF1ZyAyMyAyMDoyMjoxOCAyMDAyCnJzaEByb3k6L3Vzci9o
b21lL3JzaC9zcmMkIGNhdCBnY2MtZnAtdW51c2VkLmMNCiNpbmNsdWRlIDxzdGRpby5oPg0KDQpp
bnQgbWFpbiAoKSB7DQogICBjaGFyIGJ1ZlsyNTVdOw0KICAgaW50IGZsYWcgPSAwOw0KICAgRklM
RSAqZnA7DQoNCiAgIGlmIChmbGFnKQ0KICAgICAgZnAgPSBmb3BlbigidGVzdC50eHQiLCAiciIp
Ow0KDQogICBmb3IgKDs7KSB7DQogICAgICBpZiAoZmxhZykNCiAgICAgICAgIGZnZXRzKGJ1Ziwg
MjU1LCBmcCk7DQogICB9DQogICByZXR1cm4oMCk7DQp9DQpyc2hAcm95Oi91c3IvaG9tZS9yc2gv
c3JjJCBnY2MgLS12ZXJzaW9uDQoyLjk1LjINCnJzaEByb3k6L3Vzci9ob21lL3JzaC9zcmMkIGdj
YyAtV2FsbCBnY2MtZnAtdW51c2VkLmMNCnJzaEByb3k6L3Vzci9ob21lL3JzaC9zcmMkIGdjYyAt
TzIgLVdhbGwgZ2NjLWZwLXVudXNlZC5jDQpnY2MtZnAtdW51c2VkLmM6IEluIGZ1bmN0aW9uIGBt
YWluJzoNCmdjYy1mcC11bnVzZWQuYzo2OiB3YXJuaW5nOiBgZnAnIG1pZ2h0IGJlIHVzZWQgdW5p
bml0aWFsaXplZCBpbiB0aGlzIGZ1bmN0aW9uDQpyc2hAcm95Oi91c3IvaG9tZS9yc2gvc3JjJCB1
bmFtZSAtYQ0KTGludXggcm95IDIuMi4xOXByZTE3ICMyIE1vbiBGZWIgNCAxOToyNToyNyBHTVQg
MjAwMiBpNTg2IHVua25vd24NCnJzaEByb3k6L3Vzci9ob21lL3JzaC9zcmMkIGV4aXQNCmV4aXQN
CgpTY3JpcHQgZG9uZSBvbiBGcmkgQXVnIDIzIDIwOjIzOjM4IDIwMDIK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]