linux-2.5 min()/max() macros generate warnings with gcc-3.0.4

linux-2.5 min()/max() macros generate warnings with gcc-3.0.4

Post by Thibaut VAREN » Sun, 10 Nov 2002 02:30:08



Hi,

I'm currently trying to cleanup some warnings on 2.5 kernel tree, (especially on parisc files), and i noticed the following warnings when compiling with gcc-3.0.4:

mm/vmscan.c: In function `shrink_caches':
mm/vmscan.c:746: warning: duplicate `const'
mm/swap_state.c: In function `free_pages_and_swap_cache':
mm/swap_state.c:299: warning: duplicate `const'

in swap_state.c, the faulty line is:

        int todo = min(chunk, nr);

where chunk is "const int" and nr is "int".

min()/max() are defined in include/linux/kernel.h:145

Here is the preprocessed compiler output for swap_state.c regarding the faulty line:

        int todo = ({ const typeof(chunk) _x = (chunk); const typeof(nr) _y = (nr); (void) (&_x == &_y); _x < _y ? _x : _y; });

which should be read in particular as:
        int todo = ({ const typeof(const int chunk) _x = (const int chunk);
with types expanded.

Therefore, it seems that gcc doesn't like the redundancy of 'const' around 'typeof'.

But, according to C99, section 6.7.3 "Type qualifiers", paragraph 4, "if the same qualifier appears more than once in the same specifier-qualifier-list, [...] the behavior is the same as if it appeared only once."

So gcc shouldn't be complaining...

FWIW, casting as follow solves the warning but it definitly _evil_, since we lose const'ness:

        int todo = min((int)chunk, nr);

HTH,

Thibaut VARENE
The PA/Linux ESIEE Team
http://pateam.esiee.fr/

PS: please CC me when answering.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. gcc-2.95.3 vs gcc-3.0.4

Later versions of gcc produce larger executables, due to more aggressive
alignment of code and data.  Most of this can be turned off, but the
kernel build system isn't doing that.

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. WordPerfect word processor and LINUX?

3. v4l: crunch MIN/MAX macros.

4. How to switch back to my terminal ?

5. Error compiling kdegraphics-3.0 with gcc-3.0.4

6. Help with diald

7. gcc-3.0.4

8. How to determine bottleneck?

9. RPC compile on gcc-3.0.4

10. gcc compiler warning about getwc macro redefined

11. Help me please: GCC/ELF for 3.2v5.0.4

12. GCC & __eprintf: GCC generated from source fails to find __eprintf at linking stage

13. Same min/max io address