tsoding / something

Finally something
MIT License
53 stars 11 forks source link

Compilation error in aids.hpp #312

Open kostik1337 opened 3 years ago

kostik1337 commented 3 years ago

something.debug is compiling OK, but release is not

$ make      
cc -Wall -Wextra -Werror -pedantic -I. -x c -ggdb -DSTBI_ONLY_PNG -DSTB_IMAGE_IMPLEMENTATION -c -o stb_image.o src/stb_image.h
g++ -Wall -Wextra -Werror -pedantic -I. -std=c++17 -fno-exceptions -Wno-missing-braces -Wswitch-enum -O0 -fno-builtin -ggdb -o config_typer src/config_typer.cpp
"./config_typer" ./assets/vars.conf > config_types.hpp
g++ -Wall -Wextra -Werror -pedantic -I. -std=c++17 -fno-exceptions -Wno-missing-braces -Wswitch-enum `pkg-config --cflags sdl2` -O0 -fno-builtin -ggdb -o something.debug src/something.cpp stb_image.o `pkg-config --libs sdl2 ` -lm
g++ -Wall -Wextra -Werror -pedantic -I. -std=c++17 -fno-exceptions -Wno-missing-braces -Wswitch-enum `pkg-config --cflags sdl2` -O0 -fno-builtin -ggdb -o config_baker src/config_baker.cpp `pkg-config --libs sdl2 ` -lm
"./config_baker" > baked_config.hpp
g++ -Wall -Wextra -Werror -pedantic -I. -std=c++17 -fno-exceptions -Wno-missing-braces -Wswitch-enum `pkg-config --cflags sdl2` -DSOMETHING_RELEASE -O3 -ggdb -o something.release src/something.cpp `pkg-config --libs sdl2 ` -lm
In file included from src/something.cpp:14:
src/aids.hpp: In function ‘void command_history(Game*, aids::String_View)’:
src/aids.hpp:585:25: error: ‘snprintf’ argument 4 may overlap destination object ‘game’ [-Werror=restrict]
  585 |         int n = snprintf(
      |                 ~~~~~~~~^
  586 |             buffer->data + buffer->size,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  587 |             buffer->capacity - buffer->size,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588 |             "%.*s", (int) view.count, view.data);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/something.cpp:69:
src/something_commands.cpp:153:28: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here
  153 | void command_history(Game *game, String_View)
      |                      ~~~~~~^~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:23: something.release] Error 1
$ g++ --version
g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ lsb_release -a 
LSB Version:    1.4
Distributor ID: Arch
Description:    Arch Linux
Release:    rolling
Codename:   n/a
rexim commented 3 years ago

Duplicate of #237