Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 13527
Product:  
Component:  
Status: RESOLVED
Resolution: INVALID
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Robin Daugherty <robin@robindaugherty.net>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
failure.cpp File With The Warning text/plain 2003-12-31 14:45 337 bytes Edit
success.cpp File Without The Warning (correct behavior) text/plain 2003-12-31 14:50 339 bytes Edit
my_global.h MySQL header file text/plain 2003-12-31 15:07 9.81 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 13527 depends on: Show dependency tree
Show dependency graph
Bug 13527 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2003-12-30 22:34
In a number of seperate files, the ((unused)) attribute went ignored, causing
warnings for these lines:

static char bugs_doc[] __attribute__ ((unused)) = "Robin Daugherty";
static char version[] __attribute__ ((unused)) = "hsmdr 1.0 (2003-APR-29)";

But only if the mysql header files are included first:

// MySQL client headers
#include <mysql/my_global.h>
#include <mysql/my_sys.h>
#include <mysql/m_string.h>
#include <mysql/mysql.h>
#include <mysql/mysql_embed.h>
#include <mysql/errmsg.h>
#include <mysql/my_getopt.h>

Moving this block before the two declarations causes warnings to be issued:

hsmdr.cpp:48: warning: `char bugs_doc[16]' defined but not used
hsmdr.cpp:49: warning: `char version[24]' defined but not used

But these warnings are gone if the declaration is first.

------- Comment #1 From Andrew Pinski 2003-12-30 22:54 -------
Can you provide the preprocessed source file after reading
http://gcc.gnu.org/bugs.html.

------- Comment #2 From Robin Daugherty 2003-12-31 14:45 -------
Created an attachment (id=5388) [edit]
File With The Warning

------- Comment #3 From Robin Daugherty 2003-12-31 14:50 -------
Created an attachment (id=5389) [edit]
File Without The Warning (correct behavior)

When compiled with -Wall, this file will produce "defined but not used"
warnings only for doc, args_doc, and options.  This is correct, because
although bugs_doc and version are not used, they have the __unused__ attribute
set.

------- Comment #4 From Robin Daugherty 2003-12-31 15:07 -------
Created an attachment (id=5390) [edit]
MySQL header file

------- Comment #5 From Robin Daugherty 2003-12-31 15:10 -------
I have observed this with 3.2.1 and 3.3.2 (made with default options for x86 on
Linux).  I compile these files with -Wall (I use this option in my Makefiles).

I have attached two files, one which causes five warnings, and one which causes
only three.  The difference between them is that #include <mysql/my_global.h> is
before the definitions in the first file, but after them in the second.

Let me know if you still want preprocessed sources from me.

------- Comment #6 From Falk Hueffner 2003-12-31 15:41 -------
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  ||
__GNUC__ == 2 && __GNUC_MINOR__ < 8)
#define __attribute__(A)
#endif

There's the cuplrit. Complain to whoever provided this header file.

------- Comment #7 From Jeremy Zawodny 2004-02-17 23:03 -------
I made sure this got into MySQL AB's bug tracking system:

http://bugs.mysql.com/bug.php?id=2717

Jeremy

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug