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

[bug] Defining a variable T inside a test with DOCTEST_CONFIG_DISABLE defined does not compile #90

Closed
FSund opened this issue Sep 8, 2017 · 2 comments

Comments

@FSund
Copy link

FSund commented Sep 8, 2017

Description

Defining a variable named T inside a TEST_CASE with DOCTEST_CONFIG_DISABLE defined gives the following errors

main.cpp: In function ‘void _DOCTEST_ANON_FUNC_1()’:
main.cpp:7:12: error: declaration of ‘double T’ shadows template parameter
     double T = 273.15; // "declaration of 'double T' shadows template parameter"
            ^
In file included from main.cpp:3:0:
doctest.h:2729:15: note: template parameter ‘T’ declared here
     template <typename T>                                                                          \
               ^
doctest.h:2734:5: note: in expansion of macro ‘DOCTEST_CREATE_AND_REGISTER_FUNCTION’
     DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doctest.h:2968:19: note: in expansion of macro ‘DOCTEST_TEST_CASE’
 #define TEST_CASE DOCTEST_TEST_CASE
                   ^~~~~~~~~~~~~~~~~
main.cpp:5:1: note: in expansion of macro ‘TEST_CASE’
 TEST_CASE("test")
 ^~~~~~~~~

It seems like the section around line 2734 is not disabled even if DOCTEST_CONFIG_DISABLE is defined. Perhaps that's part of the problem?

Steps to reproduce

#define DOCTEST_CONFIG_DISABLE
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"

TEST_CASE("test")
{
    double T = 273.15; // "declaration of 'double T' shadows template parameter"
}

Compile using g++ -Wall main.cpp -o main using g++ version 6.3.0.

Extra information

  • doctest version: v1.2.2
  • Operating System: Debian 9 Stretch
  • Compiler+version: g++ 6.3.0
@onqtam
Copy link
Member

onqtam commented Sep 8, 2017

hmmm I'll have to fix this - when DOCTEST_CONFIG_DISABLE is used all test cases are turned into uninstantiated templates with T as the typename parameter - I'll change it to _DOCTEST_DISABLED_TEST_CASE_PARAMETER or something like that. Thanks for reporting!

onqtam added a commit that referenced this issue Sep 11, 2017
@onqtam
Copy link
Member

onqtam commented Sep 11, 2017

weird - the smart commit didn't close the issue when it got pushed to master even though it references the issue - closing manually.

@onqtam onqtam closed this as completed Sep 11, 2017
@onqtam onqtam changed the title Defining a variable T inside a test with DOCTEST_CONFIG_DISABLE defined does not compile [bug] Defining a variable T inside a test with DOCTEST_CONFIG_DISABLE defined does not compile Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants