[Bug c/32692] New: Inconsistent warning/error with static and non-static declarations

2007-07-09 Thread sirl at gcc dot gnu dot org
The attached testcase just produces warning or errors (depending on gcc
version) for func1, func3 and func5:

testwarning.c:5: error: static declaration of ‘func1’ follows non-static
declaration
testwarning.c:3: error: previous declaration of ‘func1’ was here
testwarning.c:25: error: static declaration of ‘func3’ follows non-static
declaration
testwarning.c:23: error: previous declaration of ‘func3’ was here
testwarning.c:46: error: static declaration of ‘func5’ follows non-static
declaration
testwarning.c:43: error: previous declaration of ‘func5’ was here

I'm not sure about any C standard implications here, but now that 'static
follows non-static' is an error in newer gcc, I believe the other way round
deserves at least a warning to. Noticed this while compiling source code with
HP's A.10.32.03 compiler, which warns about all 6 functions on the testcase
like this:
cc: "testwarning.c", line 53: warning 562: Redeclaration of "func6" with a
different storage class specifier: "func6" will have internal linkage.

Hope this helps,
Franz


-- 
   Summary: Inconsistent warning/error with static and non-static
declarations
   Product: gcc
   Version: 4.1.2
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sirl at gcc dot gnu dot org
 GCC build triplet: i586-suse-linux
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


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



[Bug c/32692] Inconsistent warning/error with static and non-static declarations

2007-07-09 Thread sirl at gcc dot gnu dot org


--- Comment #1 from sirl at gcc dot gnu dot org  2007-07-09 12:15 ---
Since attaching files doesn't seem to work right now, here a copy'n'paste:

extern int func1 (int);

static int func1 (int);

static int func1 (int in)
{
  return in;
}


static int func2 (int);

extern int func2 (int);

static int func2 (int in)
{
  return in;
}


extern int func3 (int);

static int func3 (int);

int func3 (int in)
{
  return in;
}


static int func4 (int);

extern int func4 (int);

int func4 (int in)
{
  return in;
}


extern int func5 (int);

static int func5 (int in)
{
  return in;
}


static int func6 (int);

int func6 (int in)
{
  return in;
}


-- 


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



[Bug c/32692] Inconsistent warning/error with static and non-static declarations

2007-07-09 Thread sirl at gcc dot gnu dot org


--- Comment #3 from sirl at gcc dot gnu dot org  2007-07-09 13:15 ---
Sorry, apparently I forgot to search 'All' bugs instead of just the 'Open' ones
yesterday.

One question though, how does the func6() part of the testcase relate to all
this? For this one there is no 'extern' specifier anywhere, so shouldn't
sub-clause 7 of 6.2.2 apply here and thus a warning is justified?

7 If, within a translation unit, the same identifier appears with both internal
and external linkage, the behavior is undefined.


-- 


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



[Bug c/44077] New: -Wtype-limits fails to warn for _Bool comparisons

2010-05-11 Thread sirl at gcc dot gnu dot org
For the small testcase below gcc-4.4.3 neither warns about the initialization
of var1 nor about the comparison against an integer. Nevertheless the
comparison
is optimized away.

// gcc -O2 -Wtype-limits
_Bool var1 = 3;
int test(void)
{
  if (var1 == 3)
return 1;
  return 0;
}

This maybe related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34455


-- 
   Summary: -Wtype-limits fails to warn for _Bool comparisons
   Product: gcc
   Version: 4.4.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sirl at gcc dot gnu dot org
 GCC build triplet: i686-redhat-linux
  GCC host triplet: i686-redhat-linux
GCC target triplet: i686-redhat-linux


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