IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

/usr/include/bits/string3.h:81: warning: will never be executed


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    36
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 36
    Par défaut /usr/include/bits/string3.h:81: warning: will never be executed
    Bonjour,

    Je souhaite demander votre aide à propos d'un Warning étrange que j'obtiens en compilant mon projet SDL.

    Oui, vous avez bien lu : « SDL ». Alors avant de m'envoyer balader en me disant que il existe une section pour cela sur le site, sachez que j'ai posté volontairement ce message ici car je ne pense pas qu'il y ait un quelconque rapport avec cette lib pour ce problème.

    Ce dernier, le voici, justement :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    /usr/include/bits/string3.h:81: warning: will never be executed
    /usr/include/bits/string3.h:83: warning: will never be executed
    Je présume qu'il vient d'une ligne spéciale, que voici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    memset(&in, 0, sizeof(in));
    Il faut savoir que in est une structure de type Input (que j'ai créée). La voici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    typedef struct
    	{
    		char key[SDLK_LAST];
    		char quit;
    	} Input;
    je compile avec ces options :

    gcc -ansi -O2 -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Werror-implicit-function-declaration -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wconversion -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long -Wunreachable-code `sdl-config --libs --cflags` -lSDL -lSDL_image main.c menu.c divers.c jeu.c image.c event.c -o Zério

    Merci d'avance,
    Lucas-84

    PS : Désolé si j'ai fait mauvais usages des balises, car je ne m'y retrouve pas vraiment...

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    1 104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 1 104
    Par défaut
    Il faudrait donner plus de code, car si une ligne n'est jamais exécutée, cela peut venir de plein de raisons (une condition de "if" toujours vraie ou fausse, un "return" juste avant, etc).

    Par contre, que fait un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    memset(&in, 0, sizeof(in));
    dans un fichier .h ?

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    36
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 36
    Par défaut
    Bien, voici mon code. Je vous préviens, c'est de la SDL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
     
    #include "menu.h"
    #include "constantes.h"
    #include "divers.h"
    #include "jeu.h"
    #include "image.h"
    #include "event.h"
     
    int menu(void)
    {
    	int selection = 1; /* Contient le choix du menu sélectionné */
    	int idMenu = MENU_PRINCIPAL; /* Contient l'id du menu */
     
    	int autreMenu = 0; /* Booléen qui est vrai quand l'utilisateur demande un autre menu (Options, Niveau) */
     
    	Input in; /* Pour la gestion des events */
     
    	SDL_Surface* ecran = SDL_GetVideoSurface();
    	SDL_Surface* choixMenu[3][2] = { {0, 0}, {0, 0}, {0, 0} }, *zozor, *imageDeFond;
    	SDL_Rect positionChoix[3], positionFond, positionZozor[2];
     
    	initialiserPosition(positionChoix, &positionFond, positionZozor);
     
    	chargerImagesMenu(&imageDeFond, &zozor);
     
    	memset(&in, 0, sizeof(in)); /* Met toute la structure à zéro */
     
    	while(!in.quit && !autreMenu)
    	{
    		blitterImagesMenu(imageDeFond, zozor, positionFond, positionZozor);
     
    		if(idMenu == MENU_PRINCIPAL)
    			changerSelectionPrincipal(selection, choixMenu, positionChoix);
     
    		else if(idMenu == MENU_JOUER)
    			changerSelectionJouer(selection, choixMenu, positionChoix);
     
    	    	UpdateEvents(&in);
     
    		if (in.key[SDLK_UP])
    		{
    			selection--;
    			in.key[SDLK_UP] = 0;
    		}
     
    		if (in.key[SDLK_DOWN])
    		{
    			selection++;
    			in.key[SDLK_DOWN] = 0;
    		}
     
    		if (in.key[SDLK_RETURN])
    		{
    			if(idMenu == MENU_PRINCIPAL) /* Menu principal */
    			{
    				switch(selection)		
    				{
    					case 1: /* Jouer */
    						idMenu = MENU_JOUER;
    						break;
     
    					case 2: /* Options */
    						autreMenu = 1;
    						break;
     
    					case 3: /* Quitter */
    						quitterSDL();
    						exit(0);
     
    						break;
     
    					default:break;
    				}
    			}
     
    			else
    				autreMenu = 1; /* L'utilisateur demande le menu Niveau */
     
    			in.key[SDLK_RETURN] = 0;
    		}
     
    		if (in.key[SDLK_ESCAPE])
    		{
    			if(idMenu == MENU_PRINCIPAL)
    			{
    				quitterSDL();
    				exit(0);
    			}
     
    			else
    				idMenu = MENU_PRINCIPAL;
    		}
     
    		stopper(&selection);
     
    		SDL_FillRect(SDL_GetVideoSurface(), NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
    	}
     
    	libererMemoireMenu(choixMenu, imageDeFond, zozor);
     
    	if(selection == 3) /* Si l'utilisateur a choisi « Retour » */
    		menu();
     
    	return selection;
    }
     
    /* Initialise les positions des éléments du menu */
    void initialiserPosition(SDL_Rect* positionChoix, SDL_Rect* positionFond, SDL_Rect* positionZozor)
    {
    	(*positionFond).x = 0;
        	(*positionFond).y = 0;
     
        	positionChoix[0].x = 0;
        	positionChoix[0].y = 150;
     
    	positionChoix[1].x = 0;
    	positionChoix[1].y = 250;
     
    	positionChoix[2].x = 0;
    	positionChoix[2].y = 350;
     
    	positionZozor[0].x = 10;
    	positionZozor[0].y = 10;
     
    	positionZozor[1].x = 500;
    	positionZozor[1].y = 10;
    }
     
    void libererMemoireMenu(SDL_Surface* choixMenu[][2], SDL_Surface* imageFond, SDL_Surface* zozor)
    {
    	int i, j;
     
    	for(i = 0 ; i < 3 ; i++)
    	{
    		for(j = 0 ; j < 2 ; j++)
    			SDL_FreeSurface(choixMenu[i][j]);
    	}
     
        	SDL_FreeSurface(imageFond);
     
    	SDL_FreeSurface(zozor);
    }
     
    /* Si l'utilisateur tente de descendre en-dessous de « CHOIX_3 » 
    ou au-dessus de « CHOIX_1 », on remet la sélection à l'endroit précédent */
    void stopper(int* selection)
    {
    	if((*selection) < 1)
    		(*selection) = 1;
     
    	if((*selection) > 3)
    		(*selection) = 3;
    }
    Et je pense que je me suis mal exprimé. En effet, ce code est celui de mon fichier menu.c. L'erreur se déclare dans un fichier de la bibliothèque standard, dont le chemin est /usr/include/bits/string3.h.
    Donc le warning « ne sera jamais exécuté » s'applique au fichier contenant ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    /* Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
       This file is part of the GNU C Library.
     
       The GNU C Library is free software; you can redistribute it and/or
       modify it under the terms of the GNU Lesser General Public
       License as published by the Free Software Foundation; either
       version 2.1 of the License, or (at your option) any later version.
     
       The GNU C Library is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       Lesser General Public License for more details.
     
       You should have received a copy of the GNU Lesser General Public
       License along with the GNU C Library; if not, write to the Free
       Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
       02111-1307 USA.  */
     
    #ifndef _STRING_H
    # error "Never use <bits/string3.h> directly; include <string.h> instead."
    #endif
     
    __warndecl (__warn_memset_zero_len,
    	    "memset used with constant zero length parameter; this could be due to transposed parameters");
     
    #ifndef __cplusplus
    /* XXX This is temporarily.  We should not redefine any of the symbols
       and instead integrate the error checking into the original
       definitions.  */
    # undef memcpy
    # undef memmove
    # undef memset
    # undef strcat
    # undef strcpy
    # undef strncat
    # undef strncpy
    # ifdef __USE_GNU
    #  undef mempcpy
    #  undef stpcpy
    # endif
    # ifdef __USE_BSD
    #  undef bcopy
    #  undef bzero
    # endif
    #endif
     
     
    __extern_always_inline void *
    __NTH (memcpy (void *__restrict __dest, __const void *__restrict __src,
    	       size_t __len))
    {
      return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
    }
     
    __extern_always_inline void *
    __NTH (memmove (void *__restrict __dest, __const void *__restrict __src,
    		size_t __len))
    {
      return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
    }
     
    #ifdef __USE_GNU
    __extern_always_inline void *
    __NTH (mempcpy (void *__restrict __dest, __const void *__restrict __src,
    		size_t __len))
    {
      return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest));
    }
    #endif
     
     
    /* The first two tests here help to catch a somewhat common problem
       where the second and third parameter are transposed.  This is
       especially problematic if the intended fill value is zero.  In this
       case no work is done at all.  We detect these problems by referring
       non-existing functions.  */
    __extern_always_inline void *
    __NTH (memset (void *__dest, int __ch, size_t __len))
    {
      if (__builtin_constant_p (__len) && __len == 0
          && (!__builtin_constant_p (__ch) || __ch != 0))
        {
          __warn_memset_zero_len ();
          return __dest;
        }
      return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
    }
     
    #ifdef __USE_BSD
    __extern_always_inline void
    __NTH (bcopy (__const void *__restrict __src, void *__restrict __dest,
    	      size_t __len))
    {
      (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
    }
     
    __extern_always_inline void
    __NTH (bzero (void *__dest, size_t __len))
    {
      (void) __builtin___memset_chk (__dest, '\0', __len, __bos0 (__dest));
    }
    #endif
     
    __extern_always_inline char *
    __NTH (strcpy (char *__restrict __dest, __const char *__restrict __src))
    {
      return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
    }
     
    #ifdef __USE_GNU
    __extern_always_inline char *
    __NTH (stpcpy (char *__restrict __dest, __const char *__restrict __src))
    {
      return __builtin___stpcpy_chk (__dest, __src, __bos (__dest));
    }
    #endif
     
     
    __extern_always_inline char *
    __NTH (strncpy (char *__restrict __dest, __const char *__restrict __src,
    		size_t __len))
    {
      return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
    }
     
    // XXX We have no corresponding builtin yet.
    extern char *__stpncpy_chk (char *__dest, __const char *__src, size_t __n,
    			    size_t __destlen) __THROW;
    extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest,
    					       __const char *__src,
    					       size_t __n), stpncpy);
     
    __extern_always_inline char *
    __NTH (stpncpy (char *__dest, __const char *__src, size_t __n))
    {
      if (__bos (__dest) != (size_t) -1
          && (!__builtin_constant_p (__n) || __n <= __bos (__dest)))
        return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
      return __stpncpy_alias (__dest, __src, __n);
    }
     
     
    __extern_always_inline char *
    __NTH (strcat (char *__restrict __dest, __const char *__restrict __src))
    {
      return __builtin___strcat_chk (__dest, __src, __bos (__dest));
    }
     
     
    __extern_always_inline char *
    __NTH (strncat (char *__restrict __dest, __const char *__restrict __src,
    		size_t __len))
    {
      return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
    }

Discussions similaires

  1. Warning « Will never be executed »
    Par lucas-84 dans le forum SDL
    Réponses: 1
    Dernier message: 17/02/2011, 01h05
  2. problème avec l'ouverture de fichier /usr/include/stdio.h
    Par Hisoka_Hunter dans le forum Linux
    Réponses: 1
    Dernier message: 11/12/2008, 09h28
  3. Réponses: 11
    Dernier message: 24/09/2008, 19h51
  4. Réponses: 2
    Dernier message: 09/09/2008, 02h16
  5. [gcc][bug?] warning: will never be executed
    Par PRomu@ld dans le forum Autres éditeurs
    Réponses: 16
    Dernier message: 22/08/2006, 16h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo