Error call to non-constexpr function with gcc

2,210 views
Skip to first unread message

minato

unread,
Dec 5, 2017, 9:53:26 PM12/5/17
to angleproject
When compiling with gcc, I got this error:

../src/compiler/translator/SymbolTable.cpp: In function 'constexpr const sh::TType* sh::SpecificType(const sh::TType*, int)':
../src/compiler/translator/SymbolTable.cpp:263:31: error: call to non-constexpr function 'sh::TBasicType sh::TType::getBasicType() const'
     switch (type->getBasicType())
             ~~~~~~~~~~~~~~~~~~^~
../src/compiler/translator/SymbolTable.cpp: In function 'constexpr const sh::TType* sh::VectorType(const sh::TType*, int)':
../src/compiler/translator/SymbolTable.cpp:293:31: error: call to non-constexpr function 'sh::TBasicType sh::TType::getBasicType() const'
     switch (type->getBasicType())
             ~~~~~~~~~~~~~~~~~~^~
make: *** [src/translator.target.mk:253: out/Release/obj.target/translator/src/compiler/translator/SymbolTable.o] Error 1
make: *** Waiting for unfinished jobs....

It was introduced in https://github.com/google/angle/commit/614dd0f537d4cc1d0390e7cfa0691c3f0c698399
Is it possible to fix it

Jamie Madill

unread,
Dec 6, 2017, 10:58:47 AM12/6/17
to Ihsan Akmal, kai...@chromium.org, angleproject
It should be possible to mark TType::getBasicType as constexpr, if that's the only compile problem.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ihsan Akmal

unread,
Dec 6, 2017, 11:40:48 AM12/6/17
to Jamie Madill, angleproject, kai...@chromium.org
Jamie Madill wrote:
It should be possible to mark TType::getBasicType as constexpr, if that's the only compile problem.

Which line is that so I can test it whether it fix the error or not

Jamie Madill

unread,
Dec 6, 2017, 1:55:37 PM12/6/17
to Ihsan Akmal, angleproject, kai...@chromium.org
Line 165 in Types.h, you should be able to change:

    TBasicType getBasicType() const { return type; }

to

    constexpr TBasicType getBasicType() const { return type; }

There's other places in this class you can make things contexpr if needed.

Ihsan Akmal

unread,
Dec 6, 2017, 4:07:35 PM12/6/17
to Jamie Madill, angleproject, kai...@chromium.org

Line 165 in Types.h, you should be able to change:

    TBasicType getBasicType() const { return type; }

to

    constexpr TBasicType getBasicType() const { return type; }


Yeah, you're right. That does solved the compile error with gcc. Can you included the fix in upstream?

Jamie Madill

unread,
Dec 6, 2017, 4:08:36 PM12/6/17
to Ihsan Akmal, angleproject, kai...@chromium.org
Yeah, we can do that.

kai...@chromium.org

unread,
Dec 6, 2017, 8:37:48 PM12/6/17
to angleproject

Ihsan Akmal

unread,
Dec 6, 2017, 9:50:46 PM12/6/17
to kai...@chromium.org, angleproject
Thanks
Reply all
Reply to author
Forward
0 new messages