Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang 37: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression] #1523

Closed
saper opened this issue Sep 3, 2015 · 7 comments

Comments

@saper
Copy link
Member

saper commented Sep 3, 2015

clang++37 -g -DDEBUG -DDEBUG_LVL="NONE" -Wall -DLIBSASS_VERSION="\"3.2.5-266-ge12f9\"" -std=c++0x -I /home/saper/sw/libsass/include -fPIC -fPIC -c -o src/ast.o src/ast.cpp
In file included from src/ast.cpp:1:
src/ast.hpp:2054:18: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
      if (typeid(*(*this)[0]) == typeid(Type_Selector))
                 ^
src/ast.hpp:2073:21: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
             typeid(*(*this)[0]) == typeid(Parent_Selector);
                    ^
src/ast.cpp:276:21: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
        if ((typeid(*(*rhs)[i]) == typeid(Pseudo_Selector) || typeid(*(*rhs)[i]) == typeid(Wrapped_Selector)) && (*rhs)[L-1]->is_pseudo_element())
                    ^
src/ast.cpp:276:70: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
        if ((typeid(*(*rhs)[i]) == typeid(Pseudo_Selector) || typeid(*(*rhs)[i]) == typeid(Wrapped_Selector)) && (*rhs)[L-1]->is_pseudo_element())
                                                                     ^
src/ast.cpp:284:20: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
        if (typeid(*(*rhs)[i]) == typeid(Pseudo_Selector) || typeid(*(*rhs)[i]) == typeid(Wrapped_Selector))
                   ^
src/ast.cpp:284:69: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
        if (typeid(*(*rhs)[i]) == typeid(Pseudo_Selector) || typeid(*(*rhs)[i]) == typeid(Wrapped_Selector))
                                                                    ^
6 warnings generated.
clang++37 -g -DDEBUG -DDEBUG_LVL="NONE" -Wall -DLIBSASS_VERSION="\"3.2.5-266-ge12f9\"" -std=c++0x -I /home/saper/sw/libsass/include -fPIC -fPIC -c -o src/sass_context.o src/sass_context.cpp
clang++37 -g -DDEBUG -DDEBUG_LVL="NONE" -Wall -DLIBSASS_VERSION="\"3.2.5-266-ge12f9\"" -std=c++0x -I /home/saper/sw/libsass/include -fPIC -fPIC -c -o src/sass_interface.o src/sass_interface.cpp
clang++37 -g -DDEBUG -DDEBUG_LVL="NONE" -Wall -DLIBSASS_VERSION="\"3.2.5-266-ge12f9\"" -std=c++0x -I /home/saper/sw/libsass/include -fPIC -fPIC -c -o src/util.o src/util.cpp
In file included from src/util.cpp:2:
src/ast.hpp:2054:18: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
      if (typeid(*(*this)[0]) == typeid(Type_Selector))
                 ^
src/ast.hpp:2073:21: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]
             typeid(*(*this)[0]) == typeid(Parent_Selector);
                    ^

May or may be not harmless.

@mgreter
Copy link
Contributor

mgreter commented Nov 7, 2015

Is there a "definition of done" for this Bug? I didn't see this warning so far myself? Maybe you could give some more information of used compiler and environment?

@cvrebert
Copy link

cvrebert commented Nov 7, 2015

Environment:
OS X El Capitan 10.11.1

$ c++ --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix

libsass: d18808d
sass/sassc@7efa9c4

Full build output: https://gist.github.com/cvrebert/bd95d26561e14de2cead

@mgreter
Copy link
Contributor

mgreter commented Nov 7, 2015

We don't see this on the Travis Mac OSX CI build and I don't have access or connection to any Mac, so someone else needs to step in here to analyze this further ...

@cvrebert
Copy link

cvrebert commented Nov 7, 2015

Looks like the Travis build is using an older version of clang (and possibly of OS X?):

$ clang --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0

@saper
Copy link
Member Author

saper commented Nov 7, 2015 via email

@saper
Copy link
Member Author

saper commented Nov 7, 2015 via email

@mgreter
Copy link
Contributor

mgreter commented Nov 7, 2015

Fixed in #1707

@xzyfer xzyfer added this to the 3.3.3 milestone Nov 8, 2015
@mgreter mgreter self-assigned this Jan 20, 2016
glebm added a commit to glebm/libsass that referenced this issue Dec 25, 2018
…espite being used as an operand to 'typeid'

This is not a useful warning here but simply extracting `*schema->at(0)`
to a variable avoids it.

Warning example: https://travis-ci.org/sass/libsass/jobs/471245025
Refs sass#1523
glebm added a commit to glebm/libsass that referenced this issue Dec 25, 2018
…espite being used as an operand to 'typeid'

This is not a useful warning here but simply extracting `*schema->at(0)`
to a variable avoids it.

Warning example: https://travis-ci.org/sass/libsass/jobs/471245025
Refs sass#1523
xzyfer pushed a commit that referenced this issue Feb 1, 2019
…espite being used as an operand to 'typeid'

This is not a useful warning here but simply extracting `*schema->at(0)`
to a variable avoids it.

Warning example: https://travis-ci.org/sass/libsass/jobs/471245025
Refs #1523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants