getting "strict warning: Non-static method CRM_Core_Block::setTemplateValues()" in Civi - civicrm

After I created an event, when I access the home page of the civi crm , I get the following errors:
strict warning: Non-static method CRM_Core_Block::setTemplateValues()
should not be called statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 587. strict warning: Non-static method
CRM_Core_Block::setTemplateShortcutValues() should not be called
statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 287. strict warning: Non-static method
CRM_Core_Block::setTemplateValues() should not be called statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 587. strict warning: Non-static method
CRM_Core_Block::setTemplateValues() should not be called statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 587. strict warning: Non-static method
CRM_Core_Block::setTemplateDashboardValues() should not be called
statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 291. strict warning: Non-static method
CRM_Core_Block::setTemplateValues() should not be called statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 587. strict warning: Non-static method
CRM_Core_Block::setTemplateValues() should not be called statically in
C:\xampp\htdocs\drupal\sites\all\modules\civicrm\CRM\Core\Block.php on
line 587.

This is fixed in recent versions. I suggest you upgrade to 4.3.8 or 4.4.4 (as of this post).
CRM_Core_Block.php on github shows code updated to static method

Related

Why GCC can compile std::exception("some error msg") without error?

I found the following code that is throwing an exception with a message for the parameter, but GCC can successfully compile it without any error.
When I use clang to compile, the result is failure. I want to debug the GCC compile process to find the difference with the GCC option -Q, but it seems not to work. I hope someone can give me some advice, or tell me why GCC can compile it successfully.
T* lpItem = new T;
if (NULL == lpItem)
{
throw std::exception("New CachePool Item Fail");
}
GCC is taking advantage of [member.functions] to add something like
std::exception::exception(const char *);
Clang is not
For a non-virtual member function described in the C++ standard library, an implementation may declare a different set of member function signatures, provided that any call to the member function that would select an overload from the set of declarations described in this document behaves as if that overload were selected. [ Note: For instance, an implementation may add parameters with default values, or replace a member function with default arguments with two or more member functions with equivalent behavior, or add additional signatures for a member function name. — end note ]
Emphasis added

Why does gcc warn about decltype(main()) but not clang?

Take the following code:
int main()
{
decltype(main()) x = 0;
return x;
}
gcc complains:
main.cpp: In function 'int main()':
main.cpp:8:19: warning: ISO C++ forbids taking address of function '::main' [-Wpedantic]
decltype(main()) x = 0;
^
main.cpp:8:19: warning: ISO C++ forbids taking address of function '::main' [-Wpedantic]
but not clang. So what about decltype(main()) raises this error? How does decltype take the address of main?
GCC's diagnostic might not be correctly phrased in this case, because decltype doesn't need to know the address of main; it only needs to know its type. However, the warning is based on the following from the standard (§3.6.1/3):
The function main shall not be used within a program.
I suppose GCC interprets this to mean that you can't even use it in an unevaluated expression.
Clang (version 3.4 anyway) appears to not implement this rule at all, even if I turn on all the flags I can think of and even if main calls itself recursively. That's why it doesn't give you a warning.
This topic actually came up recently in the undefined behaviour study group discussion list in the thread What does "The function main shall not be used within a program" mean?. It does not come up right away but here is where it starts in the thread with the following statement:
I don't think decltype(main()) is an odr-use, or
sizeof(decltype(main)).
a very abbreviated set of responses looks like this:
True, I just don’t see what utility those would be. You might mean
sizeof(decltype(&main)) in the latter case.
I think the most common non-ODR use of main would be defining it after
a forward declaration, and now Steven Clamage has clarified that
should be ill-formed. The broader definition of “use” as being a
result of name lookup without reference to ODR looks correct now.
and:
C++98's mention of 'use' had a cross-reference to 3.2 [basic.def.odr].
C++11 no longer has the cross-reference, and was not changed to say
'odr-use', so I expect it means any use.
and so it would seem that the interpretation of section 3.6.1 Main function which says:
The function main shall not be used within a program. [...]
means any use even in unevaluated contexts and so gcc is correct here to produce an error although the message itself does not seem to make sense.
Update
It is interesting and instructive to note that the original proposal: N3154 to fix Defect report 1109 would have changed 3.6.1 to:
The function main shall not be odr-used (3.2) within a program. ...
which would have allowed the decltype example but was amended when accepted and we can see that the new proposal: N3214 changed to what we have today:
The function main shall not be used within a program
which would strongly indicate the opinion in the UB mailing list that any use of main is ill-formed is indeed correct.

Gtest with C++11 std::condition_variable implies valgrind errors

If I write a test with google test framework this way:
TEST_F( TestFName, TestName )
{
std::condition_variable cv;
}
It generates a valgrind error. I run it with --leak-check=full --track-origins=yes options.
Conditional jump or move depends on uninitialised value(s)
==17215== at 0x4E3DA82: pthread_cond_destroy##GLIBC_2.3.2 (pthread_cond_destroy.c:35)
...
Uninitialised value was created by a stack allocation
==17215== at 0x4551D0: TestFName_TestName_test::TestBody()
It was weird to realise that the error was from the condition_variable cv declaration. When I declared it global, the error dissapeared.
I am running Valgrind-3.7.0 on a machine with Ubuntu 3.8 x86_64.
Did someone else encountered the same issue?
My wild guess, based on reading the source, is that your compilation environment does not match the environment used to compile the libstdc++ binaries you're using. Specifically, libstdc++ was compiled without _GTHREAD_USE_COND_INIT_FUNC, and it is defined in your environment.
Here is the reason: the header <condition_variable> defines a data member of a type which resolves to pthread_cond_t. If the macro __GTHREAD_COND_INIT is defined, the default initialization for this member is specified in the header, and the constructor is defaulted in the implementation file. If it's not, it is initialized with a function call in the body of a non-default constructor. Whether __GTHREAD_COND_INIT is defined is controlled by the _GTHREAD_USE_COND_INIT_FUNC macro.
If in-class member initialization is implemented in G++ the way I think it is, e.g. the in-class initializers are executed before calling the constructor, then the effect you see would occur when your libstdc++ was compiled with _GTHREAD_USE_COND_INIT_FUNC undefed, while right now it is defined in your environment somewhere. This means that the header does not provide in-class initialization and the default constructor from the library is used, leading to an uninitialized value.
Source references, in case you want to dig deeper:
https://github.com/mirrors/gcc/blob/master/libstdc%2B%2B-v3/include/std/condition_variable
https://github.com/mirrors/gcc/blob/master/libstdc%2B%2B-v3/src/c%2B%2B11/condition_variable.cc
https://github.com/mirrors/gcc/blob/master/libgcc/gthr.h
https://github.com/mirrors/gcc/blob/master/libgcc/gthr-posix.h

Using dmalloc with recent g++

I am trying to use dmalloc with g++ 4.7.
The error message i am getting are:
/usr/include/dmalloc.h:457:32: error: declaration of 'char* strdup(const char*)' has a different exception specifier
/usr/include/string.h:130:14: error: from previous declaration 'char* strdup(const char*) throw ()'
Why do C functions throw exceptions?
Can i somehow tell the compiler to ignore the throw() specifier at compile time?
...or do i have to somehow patch dmalloc?
C functions do not throw exceptions, but exceptions can propagate across C-function frames. The throw() spec tell the compiler that no exception can come out of this function, whether generated by the function or generated by some other function down the chain.
In this case you're compiling a C++ source, which happens to contain an external declaration of a function with C linkage. This alone does not allow the compiler to draw conclusions neither about the library, which contains the function, nor about the language, used to implement that function, thus the compiler cannot assume anything about exceptions and has to compile code conservatively, had the throw() spec not been put there.
You have to update and/or patch dmalloc.
Remove the declaration of strdup from dmalloc.h. It seems to play tricks with the C library that no longer work.

How to compile a dynamic library?

I've been searching the web for a couple of days and can't seem to find clear instructions on how to do this.
SQLite doesn't have math functions like, sine, cosine, etc.. I found a library that extends SQLite and adds these functions, but I can't figure out how to compile the library.
http://lhealy.livejournal.com/6306.html
I've tried just about everything (except the solution). I downloaded the SQLite source, configured and used make, then tried to build the dynamic library with the following command within the extension's source directory
gcc -fPIC func_ext.c -shared -o
libsqlitefunctions.so -Isqlite3
-Isqlite3/src
I have the sqlite3 source within this directory so the -I flags should be pointing to the correct directory. This is the error that I get.
func_ext.c:91: error: static declaration of ‘acosh’ follows non-static declaration
func_ext.c:99: error: static declaration of ‘asinh’ follows non-static declaration
func_ext.c:107: error: static declaration of ‘atanh’ follows non-static declaration
func_ext.c:403: error: conflicting types for ‘isblank’
/usr/include/ctype.h:242: error: previous definition of ‘isblank’ was here
func_ext.c: In function ‘properFunc’:
func_ext.c:422: warning: pointer targets in passing argument 1 of ‘sqlite3StrDup’ differ in signedness
func_ext.c:422: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padlFunc’:
func_ext.c:463: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padrFunc’:
func_ext.c:509: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘padcFunc’:
func_ext.c:556: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘strfilterFunc’:
func_ext.c:607: warning: pointer targets in assignment differ in signedness
func_ext.c:608: warning: pointer targets in assignment differ in signedness
func_ext.c:616: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:618: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘_substr’:
func_ext.c:654: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:659: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:664: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:665: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘charindexFunc’:
func_ext.c:716: warning: pointer targets in passing argument 1 of ‘_substr’ differ in signedness
func_ext.c:716: warning: pointer targets in passing argument 2 of ‘_substr’ differ in signedness
func_ext.c: In function ‘rightFunc’:
func_ext.c:775: warning: pointer targets in assignment differ in signedness
func_ext.c:779: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘ltrimFunc’:
func_ext.c:833: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘rtrimFunc’:
func_ext.c:851: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘trimFunc’:
func_ext.c:872: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘replaceFunc’:
func_ext.c:914: warning: pointer targets in assignment differ in signedness
func_ext.c:915: warning: pointer targets in assignment differ in signedness
func_ext.c:916: warning: pointer targets in assignment differ in signedness
func_ext.c: In function ‘reverseFunc’:
func_ext.c:975: warning: pointer targets in assignment differ in signedness
func_ext.c:982: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c: In function ‘differenceFunc’:
func_ext.c:1336: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
func_ext.c:1336: warning: pointer targets in passing argument 1 of ‘sqlite3ReadUtf8’ differ in signedness
Thank you!
Sandro
Consider using g++ instead of gcc which automaticaly sets the correct settings when compiling c++. For instance, with the following code:
int f(int x)
{
}
int f(int x, int y)
{
}
int main(int argc, char* argv[])
{
}
... gives the error:
test.c:7: error: conflicting types for ‘f’
test.c:2: error: previous definition of ‘f’ was here
Where as with g++, it's fine. It could be that the code genuinely is attempting to be c and is defining overloads which would be illegal and a bigger problem, but I'd give this a shot first.
These are compiler errors not linker errors.
You need to get your program to compile (in a normal way) before you can think of building it as a shared library.